Compare commits
9
Commits
168c3eeedc
...
v1.4.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c87f51017f | ||
|
|
a876465894 | ||
|
|
761ee25642 | ||
|
|
c56ff94a47 | ||
|
|
792047eae4 | ||
|
|
78fd859889 | ||
|
|
b93d23f31c | ||
|
|
648da0fb37 | ||
|
|
d8bb6f1671 |
No files matched your search
@@ -64,6 +64,51 @@ jobs:
|
|||||||
echo "$KEYSTORE_BASE64" | base64 -d > "$RUNNER_TEMP/release.keystore"
|
echo "$KEYSTORE_BASE64" | base64 -d > "$RUNNER_TEMP/release.keystore"
|
||||||
echo "KEYSTORE_PATH=$RUNNER_TEMP/release.keystore" >> $GITHUB_ENV
|
echo "KEYSTORE_PATH=$RUNNER_TEMP/release.keystore" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Release-Notes aus CHANGELOG.md extrahieren
|
||||||
|
run: |
|
||||||
|
VERSION="${GITHUB_REF_NAME#v}"
|
||||||
|
NOTES_FILE="$RUNNER_TEMP/release_notes.md"
|
||||||
|
|
||||||
|
extract_notes() {
|
||||||
|
awk -v ver="$1" '
|
||||||
|
/^##[[:space:]]/ {
|
||||||
|
if (found) exit
|
||||||
|
line = $0
|
||||||
|
sub(/^##[[:space:]]+/, "", line)
|
||||||
|
sub(/^\[?v?/, "", line)
|
||||||
|
if (substr(line, 1, length(ver)) == ver) {
|
||||||
|
rest = substr(line, length(ver) + 1)
|
||||||
|
if (rest ~ /^([^0-9.]|$)/) { found = 1 }
|
||||||
|
}
|
||||||
|
next
|
||||||
|
}
|
||||||
|
found { print }
|
||||||
|
' CHANGELOG.md
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -f CHANGELOG.md ]; then
|
||||||
|
extract_notes "$VERSION" > "$NOTES_FILE"
|
||||||
|
|
||||||
|
# Kein eigener Eintrag für die Beta? Dann den der Basisversion nehmen.
|
||||||
|
BASE="${VERSION%%-*}"
|
||||||
|
if ! grep -q '[^[:space:]]' "$NOTES_FILE" && [ "$BASE" != "$VERSION" ]; then
|
||||||
|
extract_notes "$BASE" > "$NOTES_FILE"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
: > "$NOTES_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# In die APK einbetten, aber nur, wenn es echte Notes gibt
|
||||||
|
mkdir -p app/src/main/assets
|
||||||
|
if grep -q '[^[:space:]]' "$NOTES_FILE"; then
|
||||||
|
cp "$NOTES_FILE" app/src/main/assets/release_notes.md
|
||||||
|
else
|
||||||
|
echo "Keine Release-Notes für Version $VERSION vorhanden." > "$NOTES_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Release-Notes:"
|
||||||
|
cat "$NOTES_FILE"
|
||||||
|
|
||||||
- name: Android Release APK bauen
|
- name: Android Release APK bauen
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -101,37 +146,6 @@ jobs:
|
|||||||
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
||||||
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
||||||
|
|
||||||
- name: Release-Notes aus CHANGELOG.md extrahieren
|
|
||||||
run: |
|
|
||||||
VERSION="${GITHUB_REF_NAME#v}"
|
|
||||||
NOTES_FILE="$RUNNER_TEMP/release_notes.md"
|
|
||||||
|
|
||||||
if [ -f CHANGELOG.md ]; then
|
|
||||||
awk -v ver="$VERSION" '
|
|
||||||
/^##[[:space:]]/ {
|
|
||||||
if (found) exit
|
|
||||||
line = $0
|
|
||||||
sub(/^##[[:space:]]+/, "", line)
|
|
||||||
sub(/^\[?v?/, "", line)
|
|
||||||
if (substr(line, 1, length(ver)) == ver) {
|
|
||||||
rest = substr(line, length(ver) + 1)
|
|
||||||
if (rest ~ /^([^0-9.]|$)/) { found = 1 }
|
|
||||||
}
|
|
||||||
next
|
|
||||||
}
|
|
||||||
found { print }
|
|
||||||
' CHANGELOG.md > "$NOTES_FILE"
|
|
||||||
else
|
|
||||||
: > "$NOTES_FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! grep -q '[^[:space:]]' "$NOTES_FILE"; then
|
|
||||||
echo "Keine Release-Notes für Version $VERSION vorhanden." > "$NOTES_FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Release-Notes:"
|
|
||||||
cat "$NOTES_FILE"
|
|
||||||
|
|
||||||
- name: Release in Gitea erstellen und APK hochladen
|
- name: Release in Gitea erstellen und APK hochladen
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
@@ -15,3 +15,4 @@
|
|||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
.cxx
|
.cxx
|
||||||
local.properties
|
local.properties
|
||||||
|
app/src/main/assets/release_notes.md
|
||||||
@@ -1,5 +1,13 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.4.4] - 2026-10-30
|
||||||
|
### New
|
||||||
|
* home screen
|
||||||
|
|
||||||
|
## [1.4.2] - 2026-10-30
|
||||||
|
### New
|
||||||
|
* show changelog after update
|
||||||
|
|
||||||
## [1.4.1] - 2026-10-30
|
## [1.4.1] - 2026-10-30
|
||||||
### New
|
### New
|
||||||
* about screen
|
* about screen
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
**One word. One week. One quality to grow.**
|
**One word. One week. One quality to grow.**
|
||||||
|
|
||||||
<a href="https://apps.obtainium.imranr.dev/redirect?r=obtainium://app/%7B%22id%22%3A%22de.schanbro.weekfocus%22%2C%22url%22%3A%22https%3A%2F%2Fgit.schamagusa.de%2Frobin%2FWeekFocus%22%2C%22author%22%3A%22robin%22%2C%22name%22%3A%22WeekFocus%22%2C%22overrideSource%22%3A%22Codeberg%22%7D">
|
<a href="https://apps.obtainium.imranr.dev/redirect?r=obtainium://app/%7B%22id%22%3A%22de.schanbro.weekfocus%22%2C%22url%22%3A%22https%3A%2F%2Fgit.schamagusa.de%Schanbro%2FWeekFocus%22%2C%22author%22%3A%Schanbro%22%2C%22name%22%3A%22WeekFocus%22%2C%22overrideSource%22%3A%22Codeberg%22%7D">
|
||||||
<img src="https://raw.githubusercontent.com/ImranR98/Obtainium/main/assets/graphics/badge_obtainium.png" alt="Get it on Obtainium" height="64">
|
<img src="https://raw.githubusercontent.com/ImranR98/Obtainium/main/assets/graphics/badge_obtainium.png" alt="Get it on Obtainium" height="64">
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
[](https://git.schamagusa.de/robin/WeekFocus/releases)
|
[](https://git.schamagusa.de/Schanbro/WeekFocus/releases)
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
<!--[](https://weblate.schamagusa.de/engage/weekfocus/)-->
|
<!--[](https://weblate.schamagusa.de/engage/weekfocus/)-->
|
||||||
|
|
||||||
@@ -22,8 +22,8 @@
|
|||||||
|
|
||||||
<!--[](https://git.schamagusa.de/Schanbro/WeekFocus)
|
<!--[](https://git.schamagusa.de/Schanbro/WeekFocus)
|
||||||
[](https://git.schamagusa.de/Schanbro/WeekFocus)-->
|
[](https://git.schamagusa.de/Schanbro/WeekFocus)-->
|
||||||
[](https://git.schamagusa.de/robin/WeekFocus/issues)
|
[](https://git.schamagusa.de/Schanbro/WeekFocus/issues)
|
||||||
[](https://git.schamagusa.de/robin/WeekFocus)
|
[](https://git.schamagusa.de/Schanbro/WeekFocus)
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ https://git.schamagusa.de/Schanbro/WeekFocus
|
|||||||
|
|
||||||
### Manual APK Install
|
### Manual APK Install
|
||||||
|
|
||||||
1. Open the [Releases](https://git.schamagusa.de/robin/WeekFocus/releases) page.
|
1. Open the [Releases](https://git.schamagusa.de/Schanbro/WeekFocus/releases) page.
|
||||||
2. Download the latest `.apk` file.
|
2. Download the latest `.apk` file.
|
||||||
3. If prompted, allow installation from unknown sources, then install the APK.
|
3. If prompted, allow installation from unknown sources, then install the APK.
|
||||||
|
|
||||||
|
|||||||
@@ -6,25 +6,21 @@ import androidx.activity.ComponentActivity
|
|||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
import androidx.compose.material.icons.filled.Home
|
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.filled.Settings
|
||||||
import androidx.compose.material.icons.outlined.Home
|
import androidx.compose.material.icons.outlined.Home
|
||||||
import androidx.compose.material.icons.outlined.List
|
|
||||||
import androidx.compose.material.icons.outlined.Settings
|
import androidx.compose.material.icons.outlined.Settings
|
||||||
import androidx.compose.material3.*
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.navigation.NavGraph.Companion.findStartDestination
|
import androidx.navigation.NavGraph.Companion.findStartDestination
|
||||||
import androidx.navigation.compose.*
|
|
||||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||||
import de.schanbro.weekfocus.screens.AboutScreen
|
import de.schanbro.weekfocus.screens.AboutScreen
|
||||||
|
import de.schanbro.weekfocus.screens.HomeScreen
|
||||||
import de.schanbro.weekfocus.screens.SettingsScreen
|
import de.schanbro.weekfocus.screens.SettingsScreen
|
||||||
import de.schanbro.weekfocus.screens.WordListScreen
|
import de.schanbro.weekfocus.screens.WordListScreen
|
||||||
import de.schanbro.weekfocus.settings.SettingsRepository
|
import de.schanbro.weekfocus.settings.SettingsRepository
|
||||||
@@ -32,6 +28,28 @@ import de.schanbro.weekfocus.settings.ThemeMode
|
|||||||
import de.schanbro.weekfocus.ui.theme.WeekFocusTheme
|
import de.schanbro.weekfocus.ui.theme.WeekFocusTheme
|
||||||
import de.schanbro.weekfocus.update.NetworkPermissionGate
|
import de.schanbro.weekfocus.update.NetworkPermissionGate
|
||||||
import de.schanbro.weekfocus.update.UpdateHandler
|
import de.schanbro.weekfocus.update.UpdateHandler
|
||||||
|
import de.schanbro.weekfocus.update.WhatsNewHandler
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.List
|
||||||
|
import androidx.compose.material.icons.automirrored.outlined.List
|
||||||
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.LargeTopAppBar
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.NavigationBar
|
||||||
|
import androidx.compose.material3.NavigationBarItem
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TopAppBar
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.navigation.compose.NavHost
|
||||||
|
import androidx.navigation.compose.composable
|
||||||
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||||
|
import androidx.navigation.compose.rememberNavController
|
||||||
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
|
|
||||||
private object Routes {
|
private object Routes {
|
||||||
const val HOME = "home"
|
const val HOME = "home"
|
||||||
@@ -40,6 +58,31 @@ private object Routes {
|
|||||||
const val ABOUT = "about"
|
const val ABOUT = "about"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private data class Tab(
|
||||||
|
val route: String,
|
||||||
|
val labelRes: Int,
|
||||||
|
val iconSelected: ImageVector,
|
||||||
|
val iconUnselected: ImageVector
|
||||||
|
)
|
||||||
|
|
||||||
|
private val tabs = listOf(
|
||||||
|
Tab(Routes.HOME, R.string.title_home, Icons.Filled.Home, Icons.Outlined.Home),
|
||||||
|
Tab(
|
||||||
|
Routes.WORDS, R.string.title_words,
|
||||||
|
Icons.AutoMirrored.Filled.List, Icons.AutoMirrored.Outlined.List
|
||||||
|
),
|
||||||
|
Tab(Routes.SETTINGS, R.string.title_settings, Icons.Filled.Settings, Icons.Outlined.Settings)
|
||||||
|
)
|
||||||
|
|
||||||
|
/** Titel im Header je Route. Hier bei Bedarf anpassen. */
|
||||||
|
private fun titleFor(route: String?): Int = when (route) {
|
||||||
|
Routes.HOME -> R.string.title_weekly_focus
|
||||||
|
Routes.WORDS -> R.string.title_words
|
||||||
|
Routes.SETTINGS -> R.string.title_settings
|
||||||
|
Routes.ABOUT -> R.string.title_about
|
||||||
|
else -> R.string.app_name
|
||||||
|
}
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
installSplashScreen()
|
installSplashScreen()
|
||||||
@@ -55,6 +98,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
WeekFocusTheme(darkTheme = darkTheme) {
|
WeekFocusTheme(darkTheme = darkTheme) {
|
||||||
MainScreen()
|
MainScreen()
|
||||||
|
WhatsNewHandler()
|
||||||
NetworkPermissionGate {
|
NetworkPermissionGate {
|
||||||
UpdateHandler()
|
UpdateHandler()
|
||||||
}
|
}
|
||||||
@@ -76,23 +120,23 @@ fun MainScreen() {
|
|||||||
val currentRoute = backStackEntry?.destination?.route
|
val currentRoute = backStackEntry?.destination?.route
|
||||||
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
|
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
|
||||||
|
|
||||||
|
fun navigateToTab(route: String) {
|
||||||
|
navController.navigate(route) {
|
||||||
|
popUpTo(navController.graph.findStartDestination().id) {
|
||||||
|
saveState = true
|
||||||
|
}
|
||||||
|
launchSingleTop = true
|
||||||
|
restoreState = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.nestedScroll(scrollBehavior.nestedScrollConnection),
|
.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||||
topBar = {
|
topBar = {
|
||||||
LargeTopAppBar(
|
LargeTopAppBar(
|
||||||
title = {
|
title = { Text(stringResource(titleFor(currentRoute))) },
|
||||||
Text(
|
|
||||||
when (currentRoute) {
|
|
||||||
Routes.HOME -> stringResource(R.string.title_weekly_focus)
|
|
||||||
Routes.WORDS -> stringResource(R.string.title_words)
|
|
||||||
Routes.SETTINGS -> stringResource(R.string.title_settings)
|
|
||||||
Routes.ABOUT -> stringResource(R.string.title_about)
|
|
||||||
else -> stringResource(R.string.app_name)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
if (currentRoute == Routes.ABOUT) {
|
if (currentRoute == Routes.ABOUT) {
|
||||||
IconButton(onClick = { navController.popBackStack() }) {
|
IconButton(onClick = { navController.popBackStack() }) {
|
||||||
@@ -111,81 +155,34 @@ fun MainScreen() {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
bottomBar = {
|
bottomBar = {
|
||||||
if (currentRoute != Routes.ABOUT) {
|
if (tabs.any { it.route == currentRoute }) {
|
||||||
NavigationBar {
|
NavigationBar {
|
||||||
|
tabs.forEach { tab ->
|
||||||
|
val selected = currentRoute == tab.route
|
||||||
NavigationBarItem(
|
NavigationBarItem(
|
||||||
selected = currentRoute == Routes.HOME,
|
selected = selected,
|
||||||
onClick = {
|
onClick = { navigateToTab(tab.route) },
|
||||||
navController.navigate(Routes.HOME) {
|
|
||||||
popUpTo(navController.graph.findStartDestination().id) {
|
|
||||||
saveState = true
|
|
||||||
}
|
|
||||||
launchSingleTop = true
|
|
||||||
restoreState = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
icon = {
|
icon = {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = if (currentRoute == Routes.HOME) Icons.Filled.Home else Icons.Outlined.Home,
|
imageVector = if (selected) tab.iconSelected else tab.iconUnselected,
|
||||||
contentDescription = stringResource(R.string.title_home)
|
contentDescription = null
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
label = { Text(stringResource(R.string.title_home)) }
|
label = { Text(stringResource(tab.labelRes)) }
|
||||||
)
|
|
||||||
NavigationBarItem(
|
|
||||||
selected = currentRoute == Routes.WORDS,
|
|
||||||
onClick = {
|
|
||||||
navController.navigate(Routes.WORDS) {
|
|
||||||
popUpTo(navController.graph.findStartDestination().id) {
|
|
||||||
saveState = true
|
|
||||||
}
|
|
||||||
launchSingleTop = true
|
|
||||||
restoreState = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
icon = {
|
|
||||||
Icon(
|
|
||||||
imageVector = if (currentRoute == Routes.WORDS) Icons.Filled.List else Icons.Outlined.List,
|
|
||||||
contentDescription = stringResource(R.string.title_words)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
label = { Text(stringResource(R.string.title_words)) }
|
|
||||||
)
|
|
||||||
NavigationBarItem(
|
|
||||||
selected = currentRoute == Routes.SETTINGS,
|
|
||||||
onClick = {
|
|
||||||
navController.navigate(Routes.SETTINGS) {
|
|
||||||
popUpTo(navController.graph.findStartDestination().id) {
|
|
||||||
saveState = true
|
|
||||||
}
|
|
||||||
launchSingleTop = true
|
|
||||||
restoreState = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
icon = {
|
|
||||||
Icon(
|
|
||||||
imageVector = if (currentRoute == Routes.SETTINGS) Icons.Filled.Settings else Icons.Outlined.Settings,
|
|
||||||
contentDescription = stringResource(R.string.title_settings)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
label = { Text(stringResource(R.string.title_settings)) }
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) { innerPadding ->
|
}
|
||||||
Surface(
|
) { padding ->
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.padding(innerPadding),
|
|
||||||
color = MaterialTheme.colorScheme.background
|
|
||||||
) {
|
|
||||||
NavHost(
|
NavHost(
|
||||||
navController = navController,
|
navController = navController,
|
||||||
startDestination = Routes.HOME,
|
startDestination = Routes.HOME,
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.padding(padding)
|
||||||
) {
|
) {
|
||||||
composable(Routes.HOME) { PlaceholderScreen(title = stringResource(R.string.title_weekly_focus)) }
|
composable(Routes.HOME) {
|
||||||
|
HomeScreen(onOpenWords = { navigateToTab(Routes.WORDS) })
|
||||||
|
}
|
||||||
composable(Routes.WORDS) { WordListScreen() }
|
composable(Routes.WORDS) { WordListScreen() }
|
||||||
composable(Routes.SETTINGS) {
|
composable(Routes.SETTINGS) {
|
||||||
SettingsScreen(onOpenAbout = { navController.navigate(Routes.ABOUT) })
|
SettingsScreen(onOpenAbout = { navController.navigate(Routes.ABOUT) })
|
||||||
@@ -193,21 +190,6 @@ fun MainScreen() {
|
|||||||
composable(Routes.ABOUT) { AboutScreen() }
|
composable(Routes.ABOUT) { AboutScreen() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun PlaceholderScreen(title: String) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier.fillMaxSize(),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = title,
|
|
||||||
style = MaterialTheme.typography.headlineMedium,
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateWidget(context: Context) {
|
fun updateWidget(context: Context) {
|
||||||
|
|||||||
@@ -11,21 +11,18 @@ import android.widget.RemoteViews
|
|||||||
import java.time.DayOfWeek
|
import java.time.DayOfWeek
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import java.time.ZoneId
|
import java.time.ZoneId
|
||||||
import java.time.temporal.ChronoUnit
|
|
||||||
import java.time.temporal.IsoFields
|
|
||||||
import java.time.temporal.TemporalAdjusters
|
import java.time.temporal.TemporalAdjusters
|
||||||
|
|
||||||
class SimpleWidget : AppWidgetProvider() {
|
class SimpleWidget : AppWidgetProvider() {
|
||||||
|
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
// Verarbeitet u.a. APPWIDGET_UPDATE / ENABLED / DISABLED und ruft die Callbacks unten auf
|
|
||||||
super.onReceive(context, intent)
|
super.onReceive(context, intent)
|
||||||
|
|
||||||
when (intent.action) {
|
when (intent.action) {
|
||||||
ACTION_WEEK_CHANGED,
|
ACTION_WEEK_CHANGED,
|
||||||
Intent.ACTION_BOOT_COMPLETED, // Alarme überleben keinen Neustart
|
Intent.ACTION_BOOT_COMPLETED,
|
||||||
Intent.ACTION_DATE_CHANGED,
|
Intent.ACTION_DATE_CHANGED,
|
||||||
Intent.ACTION_TIME_CHANGED, // "android.intent.action.TIME_SET"
|
Intent.ACTION_TIME_CHANGED,
|
||||||
Intent.ACTION_TIMEZONE_CHANGED -> updateAllWidgets(context)
|
Intent.ACTION_TIMEZONE_CHANGED -> updateAllWidgets(context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,17 +35,14 @@ class SimpleWidget : AppWidgetProvider() {
|
|||||||
for (appWidgetId in appWidgetIds) {
|
for (appWidgetId in appWidgetIds) {
|
||||||
updateAppWidget(context, appWidgetManager, appWidgetId)
|
updateAppWidget(context, appWidgetManager, appWidgetId)
|
||||||
}
|
}
|
||||||
// Selbstheilung: stellt sicher, dass immer ein Wochenwechsel-Alarm existiert
|
|
||||||
scheduleNextWeekChange(context)
|
scheduleNextWeekChange(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onEnabled(context: Context) {
|
override fun onEnabled(context: Context) {
|
||||||
// Erstes Widget wurde platziert
|
|
||||||
scheduleNextWeekChange(context)
|
scheduleNextWeekChange(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDisabled(context: Context) {
|
override fun onDisabled(context: Context) {
|
||||||
// Letztes Widget wurde entfernt
|
|
||||||
cancelWeekChange(context)
|
cancelWeekChange(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +50,6 @@ class SimpleWidget : AppWidgetProvider() {
|
|||||||
const val ACTION_WEEK_CHANGED = "de.schanbro.weekfocus.ACTION_WEEK_CHANGED"
|
const val ACTION_WEEK_CHANGED = "de.schanbro.weekfocus.ACTION_WEEK_CHANGED"
|
||||||
|
|
||||||
private const val PREFS_NAME = "WeekFocusPrefs"
|
private const val PREFS_NAME = "WeekFocusPrefs"
|
||||||
private const val KEY_WORDS = "words_key"
|
|
||||||
private const val KEY_WEEK = "current_week_key"
|
private const val KEY_WEEK = "current_week_key"
|
||||||
private const val KEY_WORD = "current_word"
|
private const val KEY_WORD = "current_word"
|
||||||
|
|
||||||
@@ -90,63 +83,50 @@ class SimpleWidget : AppWidgetProvider() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ISO-Kalenderwoche (Montag = Wochenbeginn, unabhängig von der Geräte-Locale)
|
* Holt das Wort für die aktuelle Woche unter Verwendung von WordOfWeek
|
||||||
* kombiniert mit dem zugehörigen Wochenjahr, z.B. 202641.
|
* und speichert es persistent ab, solange sich die Woche nicht ändert.
|
||||||
*
|
|
||||||
* Das Wochenjahr (nicht das Kalenderjahr!) verhindert, dass sich der Wert
|
|
||||||
* um Neujahr mitten in der Woche ändert.
|
|
||||||
*/
|
|
||||||
internal fun weekKeyFor(date: LocalDate): Int {
|
|
||||||
val weekBasedYear = date.get(IsoFields.WEEK_BASED_YEAR)
|
|
||||||
val week = date.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR)
|
|
||||||
return weekBasedYear * 100 + week
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Liefert das Wort der aktuellen Woche.
|
|
||||||
*
|
|
||||||
* - Die Liste wird sortiert, damit die Reihenfolge deterministisch ist
|
|
||||||
* (ein Set hat keine garantierte Reihenfolge).
|
|
||||||
* - Das gewählte Wort wird pro Woche gespeichert. Dadurch ändert sich das Wort
|
|
||||||
* nicht, wenn Wörter hinzugefügt oder gelöscht werden. Nur wenn das aktuelle
|
|
||||||
* Wort selbst gelöscht wird, wird neu gewählt.
|
|
||||||
*/
|
*/
|
||||||
private fun resolveWordOfWeek(context: Context): String? {
|
private fun resolveWordOfWeek(context: Context): String? {
|
||||||
val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
// Wörter sortiert laden, damit die Reihenfolge deterministisch bleibt
|
||||||
val words = (prefs.getStringSet(KEY_WORDS, emptySet()) ?: emptySet()).sorted()
|
val words = WordOfWeek.loadWords(context).sorted()
|
||||||
|
|
||||||
if (words.isEmpty()) {
|
if (words.isEmpty()) {
|
||||||
prefs.edit().remove(KEY_WEEK).remove(KEY_WORD).apply()
|
context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
||||||
|
.edit().remove(KEY_WEEK).remove(KEY_WORD).apply()
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
val weekKey = weekKeyFor(LocalDate.now())
|
val currentWeek = WordOfWeek.weekOf(0)
|
||||||
|
val weekKey = currentWeek.weekYear * 100 + currentWeek.weekNumber
|
||||||
|
|
||||||
|
val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
||||||
val storedWord = prefs.getString(KEY_WORD, null)
|
val storedWord = prefs.getString(KEY_WORD, null)
|
||||||
|
|
||||||
|
// Wenn die gespeicherte Woche passt und das gespeicherte Wort noch in der Liste existiert: behalten
|
||||||
if (prefs.getInt(KEY_WEEK, -1) == weekKey && storedWord != null && storedWord in words) {
|
if (prefs.getInt(KEY_WEEK, -1) == weekKey && storedWord != null && storedWord in words) {
|
||||||
return storedWord
|
return storedWord
|
||||||
}
|
}
|
||||||
|
|
||||||
val currentMonday = LocalDate.now().with(DayOfWeek.MONDAY)
|
// Ansonsten neu über WordOfWeek bestimmen
|
||||||
val weeksSinceEpoch = ChronoUnit.WEEKS.between(LocalDate.ofEpochDay(4), currentMonday) // 5.1.1970 war ein Montag
|
val newWord = WordOfWeek.wordFor(words, currentWeek) ?: return null
|
||||||
val word = words[(weeksSinceEpoch % words.size).toInt()]
|
|
||||||
|
|
||||||
|
// Speichern für den Rest der Woche
|
||||||
prefs.edit()
|
prefs.edit()
|
||||||
.putInt(KEY_WEEK, weekKey)
|
.putInt(KEY_WEEK, weekKey)
|
||||||
.putString(KEY_WORD, word)
|
.putString(KEY_WORD, newWord)
|
||||||
.apply()
|
.apply()
|
||||||
return word
|
|
||||||
|
return newWord
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plant einen Alarm für den nächsten Montag, 00:00 Uhr (lokale Zeit).
|
* Plant einen Alarm für den nächsten Montag, 00:00 Uhr (lokale Zeit).
|
||||||
* Bewusst ohne Exact-Alarm-Berechtigung: Eine Verzögerung von wenigen Minuten
|
|
||||||
* ist für ein Wochenwort unkritisch.
|
|
||||||
*/
|
*/
|
||||||
private fun scheduleNextWeekChange(context: Context) {
|
private fun scheduleNextWeekChange(context: Context) {
|
||||||
val alarmManager = context.getSystemService(AlarmManager::class.java) ?: return
|
val alarmManager = context.getSystemService(AlarmManager::class.java) ?: return
|
||||||
|
|
||||||
val triggerAtMillis = LocalDate.now()
|
val triggerAtMillis = LocalDate.now()
|
||||||
.with(TemporalAdjusters.next(DayOfWeek.MONDAY)) // "next" schließt heute aus
|
.with(TemporalAdjusters.next(DayOfWeek.MONDAY))
|
||||||
.atStartOfDay(ZoneId.systemDefault())
|
.atStartOfDay(ZoneId.systemDefault())
|
||||||
.toInstant()
|
.toInstant()
|
||||||
.toEpochMilli()
|
.toEpochMilli()
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package de.schanbro.weekfocus
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import java.time.DayOfWeek
|
||||||
|
import java.time.LocalDate
|
||||||
|
import java.time.temporal.IsoFields
|
||||||
|
import java.util.Random
|
||||||
|
|
||||||
|
data class WeekInfo(val monday: LocalDate) {
|
||||||
|
val sunday: LocalDate get() = monday.plusDays(6)
|
||||||
|
val weekNumber: Int get() = monday.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR)
|
||||||
|
val weekYear: Int get() = monday.get(IsoFields.WEEK_BASED_YEAR)
|
||||||
|
}
|
||||||
|
|
||||||
|
object WordOfWeek {
|
||||||
|
|
||||||
|
fun loadWords(context: Context): List<String> =
|
||||||
|
context.getSharedPreferences("WeekFocusPrefs", Context.MODE_PRIVATE)
|
||||||
|
.getStringSet("words_key", emptySet())
|
||||||
|
?.toList()
|
||||||
|
.orEmpty()
|
||||||
|
|
||||||
|
/** offset 0 = diese Woche, -1 = letzte, 1 = nächste ... */
|
||||||
|
fun weekOf(offset: Int = 0, today: LocalDate = LocalDate.now()): WeekInfo =
|
||||||
|
WeekInfo(today.with(DayOfWeek.MONDAY).plusWeeks(offset.toLong()))
|
||||||
|
|
||||||
|
fun wordFor(words: List<String>, week: WeekInfo): String? {
|
||||||
|
if (words.isEmpty()) return null
|
||||||
|
val seed = (week.weekYear * 100 + week.weekNumber).toLong()
|
||||||
|
return words[Random(seed).nextInt(words.size)]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import androidx.compose.material.icons.Icons
|
|||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@@ -18,7 +19,11 @@ import androidx.compose.ui.unit.dp
|
|||||||
import de.schanbro.weekfocus.R
|
import de.schanbro.weekfocus.R
|
||||||
import de.schanbro.weekfocus.components.ClickRow
|
import de.schanbro.weekfocus.components.ClickRow
|
||||||
import de.schanbro.weekfocus.components.SectionTitle
|
import de.schanbro.weekfocus.components.SectionTitle
|
||||||
|
import de.schanbro.weekfocus.update.ReleaseNotes
|
||||||
import de.schanbro.weekfocus.update.UpdateChecker
|
import de.schanbro.weekfocus.update.UpdateChecker
|
||||||
|
import de.schanbro.weekfocus.update.WhatsNewDialog
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
|
||||||
private const val REPO_URL = "https://git.schamagusa.de/robin/WeekFocus"
|
private const val REPO_URL = "https://git.schamagusa.de/robin/WeekFocus"
|
||||||
|
|
||||||
@@ -81,6 +86,25 @@ fun AboutScreen(
|
|||||||
onClick = { uriHandler.openUri("$REPO_URL/releases") }
|
onClick = { uriHandler.openUri("$REPO_URL/releases") }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
HorizontalDivider()
|
||||||
|
|
||||||
|
SectionTitle(stringResource(R.string.about_whats_new_section_title))
|
||||||
|
|
||||||
|
var showNotes by remember { mutableStateOf(false) }
|
||||||
|
val notes = remember { ReleaseNotes.load(context) }
|
||||||
|
|
||||||
|
if (notes != null) {
|
||||||
|
ClickRow(
|
||||||
|
title = stringResource(R.string.about_whats_new_title),
|
||||||
|
summary = stringResource(R.string.about_whats_new_summary),
|
||||||
|
onClick = { showNotes = true }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showNotes && notes != null) {
|
||||||
|
WhatsNewDialog(version = version, notes = notes, onDismiss = { showNotes = false })
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(Modifier.height(16.dp))
|
Spacer(Modifier.height(16.dp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,328 @@
|
|||||||
|
package de.schanbro.weekfocus.screens
|
||||||
|
|
||||||
|
import android.appwidget.AppWidgetManager
|
||||||
|
import android.content.ComponentName
|
||||||
|
import android.content.Context
|
||||||
|
import android.text.format.DateUtils
|
||||||
|
import androidx.compose.animation.AnimatedContent
|
||||||
|
import androidx.compose.animation.fadeIn
|
||||||
|
import androidx.compose.animation.fadeOut
|
||||||
|
import androidx.compose.animation.slideInHorizontally
|
||||||
|
import androidx.compose.animation.slideOutHorizontally
|
||||||
|
import androidx.compose.animation.togetherWith
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
|
import androidx.compose.foundation.layout.*
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowLeft
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
|
||||||
|
import androidx.compose.material.icons.filled.Check
|
||||||
|
import androidx.compose.material3.*
|
||||||
|
import androidx.compose.runtime.*
|
||||||
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.lifecycle.compose.LifecycleEventEffect
|
||||||
|
import de.schanbro.weekfocus.R
|
||||||
|
import de.schanbro.weekfocus.SimpleWidget
|
||||||
|
import de.schanbro.weekfocus.WeekInfo
|
||||||
|
import de.schanbro.weekfocus.WordOfWeek
|
||||||
|
import java.time.LocalDate
|
||||||
|
import java.time.ZoneId
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun HomeScreen(
|
||||||
|
onOpenWords: () -> Unit,
|
||||||
|
modifier: Modifier = Modifier
|
||||||
|
) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val haptic = LocalHapticFeedback.current
|
||||||
|
|
||||||
|
var words by remember { mutableStateOf(WordOfWeek.loadWords(context)) }
|
||||||
|
var widgetPlaced by remember { mutableStateOf(true) } // true = kein Flackern beim Start
|
||||||
|
var weekOffset by rememberSaveable { mutableIntStateOf(0) }
|
||||||
|
val canPinWidget = remember {
|
||||||
|
AppWidgetManager.getInstance(context).isRequestPinAppWidgetSupported
|
||||||
|
}
|
||||||
|
|
||||||
|
// Beim Zurückkehren (Wörter-Tab, Launcher, Widget) neu laden
|
||||||
|
LifecycleEventEffect(Lifecycle.Event.ON_RESUME) {
|
||||||
|
words = WordOfWeek.loadWords(context)
|
||||||
|
widgetPlaced = isWidgetPlaced(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun changeOffset(new: Int) {
|
||||||
|
haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove)
|
||||||
|
weekOffset = new
|
||||||
|
}
|
||||||
|
|
||||||
|
Column(
|
||||||
|
modifier = modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.verticalScroll(rememberScrollState())
|
||||||
|
.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||||
|
) {
|
||||||
|
if (words.isEmpty()) {
|
||||||
|
EmptyCard(onOpenWords)
|
||||||
|
} else {
|
||||||
|
WordHeroCard(words, weekOffset, ::changeOffset)
|
||||||
|
WeeksCard(words, weekOffset, ::changeOffset)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!widgetPlaced && canPinWidget) {
|
||||||
|
WidgetCard(
|
||||||
|
onAdd = {
|
||||||
|
AppWidgetManager.getInstance(context).requestPinAppWidget(
|
||||||
|
ComponentName(context, SimpleWidget::class.java), null, null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(Modifier.height(8.dp))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun WordHeroCard(
|
||||||
|
words: List<String>,
|
||||||
|
weekOffset: Int,
|
||||||
|
onOffsetChange: (Int) -> Unit
|
||||||
|
) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val week = WordOfWeek.weekOf(weekOffset)
|
||||||
|
val onColor = MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
|
|
||||||
|
Card(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
shape = MaterialTheme.shapes.extraLarge,
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||||
|
contentColor = onColor
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.padding(16.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
IconButton(onClick = { onOffsetChange(weekOffset - 1) }) {
|
||||||
|
Icon(
|
||||||
|
Icons.AutoMirrored.Filled.KeyboardArrowLeft,
|
||||||
|
contentDescription = stringResource(R.string.home_cd_previous)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = weekLabel(weekOffset, week),
|
||||||
|
style = MaterialTheme.typography.labelLarge
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = stringResource(
|
||||||
|
R.string.home_week_range,
|
||||||
|
week.weekNumber,
|
||||||
|
formatRange(context, week)
|
||||||
|
),
|
||||||
|
style = MaterialTheme.typography.bodySmall
|
||||||
|
)
|
||||||
|
}
|
||||||
|
IconButton(onClick = { onOffsetChange(weekOffset + 1) }) {
|
||||||
|
Icon(
|
||||||
|
Icons.AutoMirrored.Filled.KeyboardArrowRight,
|
||||||
|
contentDescription = stringResource(R.string.home_cd_next)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimatedContent(
|
||||||
|
targetState = weekOffset,
|
||||||
|
transitionSpec = {
|
||||||
|
val dir = if (targetState > initialState) 1 else -1
|
||||||
|
(slideInHorizontally { width -> width * dir } + fadeIn()) togetherWith
|
||||||
|
(slideOutHorizontally { width -> -width * dir } + fadeOut())
|
||||||
|
},
|
||||||
|
label = "word"
|
||||||
|
) { offset ->
|
||||||
|
Text(
|
||||||
|
text = WordOfWeek.wordFor(words, WordOfWeek.weekOf(offset)).orEmpty(),
|
||||||
|
style = MaterialTheme.typography.displaySmall,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(vertical = 32.dp, horizontal = 8.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (weekOffset == 0) {
|
||||||
|
val day = remember { LocalDate.now().dayOfWeek.value } // 1 = Mo ... 7 = So
|
||||||
|
LinearProgressIndicator(
|
||||||
|
progress = { day / 7f },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
color = onColor,
|
||||||
|
trackColor = onColor.copy(alpha = 0.15f)
|
||||||
|
)
|
||||||
|
Spacer(Modifier.height(8.dp))
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.home_day_progress, day),
|
||||||
|
style = MaterialTheme.typography.bodySmall
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
FilledTonalButton(onClick = { onOffsetChange(0) }) {
|
||||||
|
Text(stringResource(R.string.home_back_to_current))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun WeeksCard(
|
||||||
|
words: List<String>,
|
||||||
|
selectedOffset: Int,
|
||||||
|
onOffsetChange: (Int) -> Unit
|
||||||
|
) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
|
||||||
|
Column {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.home_more_weeks),
|
||||||
|
style = MaterialTheme.typography.labelLarge,
|
||||||
|
color = MaterialTheme.colorScheme.primary,
|
||||||
|
modifier = Modifier.padding(start = 4.dp, bottom = 8.dp)
|
||||||
|
)
|
||||||
|
Card(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
shape = MaterialTheme.shapes.large,
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.surfaceContainerLow
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
listOf(-2, -1, 0, 1, 2, 3).forEach { offset ->
|
||||||
|
val week = WordOfWeek.weekOf(offset)
|
||||||
|
ListItem(
|
||||||
|
overlineContent = {
|
||||||
|
Text(
|
||||||
|
stringResource(
|
||||||
|
R.string.home_week_range,
|
||||||
|
week.weekNumber,
|
||||||
|
formatRange(context, week)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
headlineContent = {
|
||||||
|
Text(WordOfWeek.wordFor(words, week).orEmpty())
|
||||||
|
},
|
||||||
|
trailingContent = {
|
||||||
|
if (offset == selectedOffset) {
|
||||||
|
Icon(Icons.Default.Check, contentDescription = null)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
colors = ListItemDefaults.colors(containerColor = Color.Transparent),
|
||||||
|
modifier = Modifier.clickable { onOffsetChange(offset) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.home_preview_hint),
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
modifier = Modifier.padding(start = 4.dp, top = 8.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun EmptyCard(onOpenWords: () -> Unit) {
|
||||||
|
Card(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
shape = MaterialTheme.shapes.extraLarge,
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.surfaceContainerLow
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(24.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.msg_no_words_yet),
|
||||||
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
Button(onClick = onOpenWords) {
|
||||||
|
Text(stringResource(R.string.hint_add_word))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun WidgetCard(onAdd: () -> Unit) {
|
||||||
|
Card(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
shape = MaterialTheme.shapes.large,
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.home_widget_title),
|
||||||
|
style = MaterialTheme.typography.titleMedium
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.home_widget_message),
|
||||||
|
style = MaterialTheme.typography.bodyMedium
|
||||||
|
)
|
||||||
|
Spacer(Modifier.height(8.dp))
|
||||||
|
FilledTonalButton(onClick = onAdd) {
|
||||||
|
Text(stringResource(R.string.home_widget_action))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun weekLabel(offset: Int, week: WeekInfo): String = when (offset) {
|
||||||
|
0 -> stringResource(R.string.home_this_week)
|
||||||
|
1 -> stringResource(R.string.home_next_week)
|
||||||
|
-1 -> stringResource(R.string.home_last_week)
|
||||||
|
else -> stringResource(R.string.home_calendar_week, week.weekNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun formatRange(context: Context, week: WeekInfo): String {
|
||||||
|
val zone = ZoneId.systemDefault()
|
||||||
|
val start = week.monday.atStartOfDay(zone).toInstant().toEpochMilli()
|
||||||
|
val end = week.sunday.atStartOfDay(zone).toInstant().toEpochMilli()
|
||||||
|
return DateUtils.formatDateRange(
|
||||||
|
context, start, end,
|
||||||
|
DateUtils.FORMAT_SHOW_DATE or DateUtils.FORMAT_ABBREV_MONTH or DateUtils.FORMAT_NO_YEAR
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isWidgetPlaced(context: Context): Boolean =
|
||||||
|
AppWidgetManager.getInstance(context)
|
||||||
|
.getAppWidgetIds(ComponentName(context, SimpleWidget::class.java))
|
||||||
|
.isNotEmpty()
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package de.schanbro.weekfocus.update
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
object ReleaseNotes {
|
||||||
|
|
||||||
|
/** Liefert die eingebetteten Notes oder null (z. B. bei lokalen Builds). */
|
||||||
|
fun load(context: Context): String? = try {
|
||||||
|
context.assets.open("release_notes.md")
|
||||||
|
.bufferedReader().use { it.readText() }
|
||||||
|
.trim()
|
||||||
|
.ifEmpty { null }
|
||||||
|
} catch (e: IOException) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Einfache Markdown-Bereinigung für die Anzeige als Text. */
|
||||||
|
fun format(markdown: String): String =
|
||||||
|
markdown.lines()
|
||||||
|
.joinToString("\n") { line ->
|
||||||
|
line.trimEnd()
|
||||||
|
.replace(Regex("^#{1,6}\\s*"), "")
|
||||||
|
.replace(Regex("^\\s*[-*]\\s+"), "• ")
|
||||||
|
.replace("**", "")
|
||||||
|
}
|
||||||
|
.replace(Regex("\n{3,}"), "\n\n")
|
||||||
|
.trim()
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package de.schanbro.weekfocus.update
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material3.*
|
||||||
|
import androidx.compose.runtime.*
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import de.schanbro.weekfocus.R
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
|
private const val KEY_LAST_SEEN = "last_seen_version"
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun WhatsNewHandler() {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val prefs = remember {
|
||||||
|
context.getSharedPreferences("WeekFocusPrefs", Context.MODE_PRIVATE)
|
||||||
|
}
|
||||||
|
val current = remember { UpdateChecker.currentVersion(context) }
|
||||||
|
var notes by remember { mutableStateOf<String?>(null) }
|
||||||
|
|
||||||
|
fun markSeen() = prefs.edit().putString(KEY_LAST_SEEN, current).apply()
|
||||||
|
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
val lastSeen = prefs.getString(KEY_LAST_SEEN, null)
|
||||||
|
|
||||||
|
// Erster Start nach Neuinstallation: nichts anzeigen, nur merken
|
||||||
|
if (lastSeen == null) {
|
||||||
|
markSeen()
|
||||||
|
return@LaunchedEffect
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UpdateChecker.isNewer(current, lastSeen)) {
|
||||||
|
val loaded = withContext(Dispatchers.IO) { ReleaseNotes.load(context) }
|
||||||
|
if (loaded != null) notes = loaded else markSeen()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
notes?.let {
|
||||||
|
WhatsNewDialog(
|
||||||
|
version = current,
|
||||||
|
notes = it,
|
||||||
|
onDismiss = {
|
||||||
|
markSeen()
|
||||||
|
notes = null
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun WhatsNewDialog(version: String, notes: String, onDismiss: () -> Unit) {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = onDismiss,
|
||||||
|
title = { Text(stringResource(R.string.whats_new_title, version)) },
|
||||||
|
text = {
|
||||||
|
Column(Modifier.verticalScroll(rememberScrollState())) {
|
||||||
|
Text(
|
||||||
|
text = ReleaseNotes.format(notes),
|
||||||
|
style = MaterialTheme.typography.bodyMedium
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
confirmButton = {
|
||||||
|
TextButton(onClick = onDismiss) {
|
||||||
|
Text(stringResource(R.string.whats_new_close))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -64,4 +64,25 @@
|
|||||||
<string name="about_issues_summary">Bugs and requests in the issue tracker</string>
|
<string name="about_issues_summary">Bugs and requests in the issue tracker</string>
|
||||||
<string name="about_releases_title">Releases</string>
|
<string name="about_releases_title">Releases</string>
|
||||||
<string name="about_releases_summary">See all releases and changes</string>
|
<string name="about_releases_summary">See all releases and changes</string>
|
||||||
|
|
||||||
|
<string name="whats_new_title">What’s new in version %1$s</string>
|
||||||
|
<string name="whats_new_close">Got it</string>
|
||||||
|
<string name="about_whats_new_title">What’s new</string>
|
||||||
|
<string name="about_whats_new_summary">See the changes in this version</string>
|
||||||
|
<string name="about_whats_new_section_title">Changes</string>
|
||||||
|
|
||||||
|
<string name="home_this_week">This week</string>
|
||||||
|
<string name="home_next_week">Next week</string>
|
||||||
|
<string name="home_last_week">Last week</string>
|
||||||
|
<string name="home_calendar_week">Week %1$d</string>
|
||||||
|
<string name="home_week_range">Week %1$d · %2$s</string>
|
||||||
|
<string name="home_cd_previous">Previous week</string>
|
||||||
|
<string name="home_cd_next">Show next week</string>
|
||||||
|
<string name="home_back_to_current">Back to this week</string>
|
||||||
|
<string name="home_day_progress">Day %1$d of 7</string>
|
||||||
|
<string name="home_more_weeks">More weeks</string>
|
||||||
|
<string name="home_preview_hint">The preview is based on your current word list and changes whenever you add, edit or remove words.</string>
|
||||||
|
<string name="home_widget_title">Add widget</string>
|
||||||
|
<string name="home_widget_message">Show your word of the week right on your home screen.</string>
|
||||||
|
<string name="home_widget_action">Add</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -71,4 +71,26 @@
|
|||||||
<string name="about_issues_summary">Probleme und Wünsche im Issue-Tracker</string>
|
<string name="about_issues_summary">Probleme und Wünsche im Issue-Tracker</string>
|
||||||
<string name="about_releases_title">Versionen</string>
|
<string name="about_releases_title">Versionen</string>
|
||||||
<string name="about_releases_summary">Alle Releases und Änderungen ansehen</string>
|
<string name="about_releases_summary">Alle Releases und Änderungen ansehen</string>
|
||||||
|
|
||||||
|
<string name="whats_new_title">Neu in Version %1$s</string>
|
||||||
|
<string name="whats_new_close">Alles klar</string>
|
||||||
|
<string name="about_whats_new_title">Was ist neu</string>
|
||||||
|
<string name="about_whats_new_summary">Änderungen dieser Version ansehen</string>
|
||||||
|
<string name="about_whats_new_section_title">Änderungen</string>
|
||||||
|
|
||||||
|
<!-- Home Screen-->
|
||||||
|
<string name="home_this_week">Diese Woche</string>
|
||||||
|
<string name="home_next_week">Nächste Woche</string>
|
||||||
|
<string name="home_last_week">Letzte Woche</string>
|
||||||
|
<string name="home_calendar_week">Kalenderwoche %1$d</string>
|
||||||
|
<string name="home_week_range">KW %1$d · %2$s</string>
|
||||||
|
<string name="home_cd_previous">Vorherige Woche</string>
|
||||||
|
<string name="home_cd_next">Nächste Woche anzeigen</string>
|
||||||
|
<string name="home_back_to_current">Zur aktuellen Woche</string>
|
||||||
|
<string name="home_day_progress">Tag %1$d von 7</string>
|
||||||
|
<string name="home_more_weeks">Weitere Wochen</string>
|
||||||
|
<string name="home_preview_hint">Die Vorschau richtet sich nach deiner aktuellen Wortliste und ändert sich, sobald du Wörter hinzufügst, bearbeitest oder entfernst.</string>
|
||||||
|
<string name="home_widget_title">Widget hinzufügen</string>
|
||||||
|
<string name="home_widget_message">Zeige dein Wort der Woche direkt auf dem Startbildschirm.</string>
|
||||||
|
<string name="home_widget_action">Hinzufügen</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in new issue
Block a user