Fixed schedule not showing properly for certain devices due to OEM differences
Fixed notification displaying the wrong time
This commit is contained in:
1 parent
3df28a3a9a
commit
9ecc96e92b
4 files changed
+26
-4
No files matched your search
+7
@@ -30,9 +30,12 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.anthonyla.paperize.core.SettingsConstants
|
||||
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsEvent
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsViewModel
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsEvent
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsViewModel
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.themes.PaperizeTheme
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperEvent
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperScreenViewModel
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_service.WallpaperService
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
@@ -45,6 +48,7 @@ import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class MainActivity : ComponentActivity() {
|
||||
private val albumsViewModel: AlbumsViewModel by viewModels()
|
||||
private val settingsViewModel: SettingsViewModel by viewModels()
|
||||
private val wallpaperScreenViewModel: WallpaperScreenViewModel by viewModels()
|
||||
private val context = this
|
||||
@@ -79,6 +83,9 @@ class MainActivity : ComponentActivity() {
|
||||
val isFirstLaunch = runBlocking { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) } ?: true
|
||||
|
||||
if (isFirstLaunch) {
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset)
|
||||
settingsViewModel.onEvent(SettingsEvent.Reset)
|
||||
albumsViewModel.onEvent(AlbumsEvent.Reset)
|
||||
val contentResolver = context.contentResolver
|
||||
val persistedUris = contentResolver.persistedUriPermissions
|
||||
for (permission in persistedUris) {
|
||||
|
||||
-1
@@ -137,7 +137,6 @@ fun SettingsScrollableSettings(
|
||||
animate = state.value.animate,
|
||||
onAnimateClick = { onAnimateClick(it) }
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
ListSectionTitle(stringResource(R.string.about))
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
+10
@@ -62,6 +62,11 @@ fun CurrentAndNextChange(
|
||||
Text(parts[0].replace(',', ' '), style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text(parts[1], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
}
|
||||
else if (parts.size == 3) {
|
||||
Text(stringResource(R.string.last_change), style = textFirst, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text(parts[0].replace(',', ' '), style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text(parts[1] + ' ' + parts[2], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +97,11 @@ fun CurrentAndNextChange(
|
||||
Text(parts[0].replace(',', ' '), style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text(parts[1], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
}
|
||||
else if (parts.size == 3) {
|
||||
Text(stringResource(R.string.last_change), style = textFirst, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text(parts[0].replace(',', ' '), style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text(parts[1] + ' ' + parts[2], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-3
@@ -299,17 +299,23 @@ class WallpaperService: Service() {
|
||||
*/
|
||||
private fun createNotification(): Notification {
|
||||
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||
val earliestTime = when {
|
||||
var earliestTime = when {
|
||||
nextSetTime1 != null && nextSetTime2 != null -> (if (nextSetTime1!!.isBefore(nextSetTime2)) nextSetTime1 else nextSetTime2)!!.format(formatter)
|
||||
nextSetTime1 != null -> nextSetTime1!!.format(formatter)
|
||||
nextSetTime2 != null -> nextSetTime2!!.format(formatter)
|
||||
else -> null
|
||||
else -> LocalDateTime.now().format(formatter)
|
||||
}
|
||||
if (earliestTime != null) { // Edge case where numbers like 2131689515 pass through
|
||||
if (earliestTime.length <= 10) {
|
||||
earliestTime = LocalDateTime.now().format(formatter)
|
||||
}
|
||||
}
|
||||
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
return NotificationCompat.Builder(this, "wallpaper_service_channel")
|
||||
.setContentTitle(getString(R.string.app_name))
|
||||
.setContentText(getString(R.string.next_wallpaper_change, earliestTime ?: R.string.app_name))
|
||||
.setContentText(getString(R.string.next_wallpaper_change, earliestTime))
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setContentIntent(pendingIntent)
|
||||
.build()
|
||||
|
||||
Reference in new issue
Block a user