Skip to content

Commit

Permalink
Refactored collapsable top bar for settings page
Browse files Browse the repository at this point in the history
Updated permission to USE_EXACT_ALARM
Updated dependencies
  • Loading branch information
Anthonyy232 committed Oct 3, 2024
1 parent 9a31467 commit 7f32f76
Show file tree
Hide file tree
Showing 17 changed files with 432 additions and 803 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ I would love some help translating the app! Help me out with that [here](https:/
- [Zoomable](https://github.com/usuiat/Zoomable) - A library that provides a zoomable and pannable view, which can be used with any view you want
- [AnimatedFABMenu](https://github.com/rajaumair7890/AnimatedFABMenu) - A animated floating action button with Material 3 design
- [DocumentFileCompat](https://github.com/ItzNotABug/DocumentFileCompat) - A DocumentFile wrapper that caches the result to improve efficiency
- [LazyColumnScrollbar](https://github.com/nanihadesuka/LazyColumnScrollbar) - A Jetpack Compose scrollbar library
- [LazyColumnScrollbar](https://github.com/nanihadesuka/LazyColumnScrollbar) - A Compose scrollbar library
- [compose-collapsing-toolbar](https://github.com/onebone/compose-collapsing-toolbar) - A Compose library that provides a collapsing toolbar

Thanks to the creators and maintainers of the open-source libraries used in this project.

Expand Down
30 changes: 11 additions & 19 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ android {
applicationId = "com.anthonyla.paperize"
minSdk = 26
targetSdk = 35
versionCode = 31
versionName = "2.2.1"
versionCode = 32
versionName = "2.3.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
Expand All @@ -34,9 +34,6 @@ android {
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
ndk {
debugSymbolLevel = "FULL"
}
}
}

Expand All @@ -47,7 +44,6 @@ android {

kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += strongSkippingConfiguration()
}

buildFeatures {
Expand Down Expand Up @@ -86,12 +82,12 @@ dependencies {
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.6")
implementation("androidx.activity:activity-compose:1.9.2")
implementation(platform("androidx.compose:compose-bom:2024.09.02"))
implementation(platform("androidx.compose:compose-bom:2024.09.03"))
implementation("androidx.compose.ui:ui:1.7.3")
implementation("androidx.compose.ui:ui-graphics:1.7.3")
implementation("androidx.compose.ui:ui-tooling-preview:1.7.2")
implementation("androidx.compose.ui:ui-tooling-preview:1.7.3")
implementation("androidx.compose.material3:material3:1.3.0")
implementation("androidx.navigation:navigation-compose:2.8.1")
implementation("androidx.navigation:navigation-compose:2.8.2")
implementation("androidx.compose.material:material:1.7.3")
implementation("androidx.datastore:datastore:1.1.1")
implementation("androidx.datastore:datastore-preferences:1.1.1")
Expand All @@ -104,7 +100,7 @@ dependencies {
implementation("androidx.documentfile:documentfile:1.1.0-alpha01")
implementation("net.engawapg.lib:zoomable:2.0.0-beta01")
implementation("com.github.skydoves:landscapist-glide:2.4.0")
implementation("androidx.work:work-runtime-ktx:2.10.0-alpha04")
implementation("androidx.work:work-runtime-ktx:2.10.0-beta01")
implementation("androidx.hilt:hilt-work:1.2.0")
implementation("com.airbnb.android:lottie-compose:6.5.2")
implementation("com.google.accompanist:accompanist-permissions:0.36.0")
Expand All @@ -117,9 +113,9 @@ dependencies {
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.7.2")
debugImplementation("androidx.compose.ui:ui-tooling:1.7.2")
debugImplementation("androidx.compose.ui:ui-test-manifest:1.7.2")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.7.3")
debugImplementation("androidx.compose.ui:ui-tooling:1.7.3")
debugImplementation("androidx.compose.ui:ui-test-manifest:1.7.3")
implementation("com.google.dagger:hilt-android:2.52")
ksp("com.google.dagger:hilt-android-compiler:2.52")
implementation("androidx.room:room-runtime:2.6.1")
Expand All @@ -128,9 +124,5 @@ dependencies {
implementation("com.lazygeniouz:dfc:1.0.8")
implementation ("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
implementation("com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3")
}

private fun strongSkippingConfiguration() = listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:experimentalStrongSkipping=true",
)
implementation("me.onebone:toolbar-compose:2.3.5")
}
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Expand Down Expand Up @@ -34,8 +34,8 @@
android:theme="@android:style/Theme.NoDisplay">
</activity>
<receiver android:name=".feature.wallpaper.wallpaper_alarmmanager.WallpaperReceiver" />
<service android:name=".feature.wallpaper.wallpaper_service.HomeWallpaperService"/>
<service android:name=".feature.wallpaper.wallpaper_service.LockWallpaperService"/>
<service android:name=".feature.wallpaper.wallpaper_service.HomeWallpaperService" />
<service android:name=".feature.wallpaper.wallpaper_service.LockWallpaperService" />
<service
android:name=".feature.wallpaper.wallpaper_tile.ChangeWallpaperTileService"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ package com.anthonyla.paperize.data
import android.content.Context
import android.content.Intent
import android.net.Uri
import androidx.compose.runtime.Composable
import androidx.core.content.ContextCompat.startActivity

/**
* Opens an email intent to contact the developer.
*/
@Composable
fun Contact(context: Context) {
fun SendContactIntent(context: Context) {
val authorEmail = "anthonyyla.dev@gmail.com"
val cc = ""
val subject = "[Support] Paperize"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import androidx.activity.SystemBarStyle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.annotation.RequiresApi
import androidx.compose.material3.Surface
import androidx.compose.ui.unit.dp
import androidx.core.animation.doOnEnd
Expand Down Expand Up @@ -55,7 +54,6 @@ class MainActivity : ComponentActivity() {
private val settingsViewModel: SettingsViewModel by viewModels()
private val wallpaperScreenViewModel: WallpaperScreenViewModel by viewModels()
private val context = this
private var topInset = 0.dp
@Inject lateinit var settingsDataStoreImpl: SettingsDataStore
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -169,7 +167,7 @@ class MainActivity : ComponentActivity() {

PaperizeTheme(settingsState.value.darkMode, settingsState.value.amoledTheme, settingsState.value.dynamicTheming) {
Surface(tonalElevation = 5.dp) {
PaperizeApp(isFirstLaunch, scheduler, topInset)
PaperizeApp(isFirstLaunch, scheduler)
}
}
}
Expand All @@ -188,12 +186,6 @@ class MainActivity : ComponentActivity() {
}
}

@RequiresApi(Build.VERSION_CODES.P)
override fun onAttachedToWindow() {
super.onAttachedToWindow()
topInset = window.decorView.rootWindowInsets.stableInsetTop.dp
}

private fun isPendingIntentSet(requestCode: Int): Boolean {
val intent = Intent(context.applicationContext, WallpaperReceiver::class.java)
val pendingIntent = PendingIntent.getBroadcast(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.Dp
import androidx.core.content.ContextCompat
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.toRoute
import com.anthonyla.paperize.data.SendContactIntent
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.AddAlbumEvent
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.AddAlbumScreen
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.AddAlbumViewModel
Expand Down Expand Up @@ -65,7 +65,6 @@ import kotlinx.coroutines.withContext
fun PaperizeApp(
firstLaunch: Boolean,
scheduler : WallpaperAlarmSchedulerImpl,
topInsets: Dp,
albumsViewModel: AlbumsViewModel = hiltViewModel(),
settingsViewModel: SettingsViewModel = hiltViewModel(),
wallpaperScreenViewModel: WallpaperScreenViewModel = hiltViewModel(),
Expand All @@ -91,7 +90,7 @@ fun PaperizeApp(
if (navController.currentDestination?.route == Home::class.simpleName) {
try {
navController.popBackStack<Home>(inclusive = false)
} catch (e: Exception) {
} catch (_: Exception) {
navController.navigate(Home)
}
}
Expand Down Expand Up @@ -482,7 +481,7 @@ fun PaperizeApp(
},
onDarkCheck = {
settingsViewModel.onEvent(SettingsEvent.SetDarken(it))
if (settingsState.value.enableChanger && (it && settingsState.value.homeDarkenPercentage < 100)) {
if (settingsState.value.enableChanger) {
job?.cancel()
job = scope.launch {
delay(1000)
Expand Down Expand Up @@ -671,7 +670,7 @@ fun PaperizeApp(
},
onBlurChange = {
settingsViewModel.onEvent(SettingsEvent.SetBlur(it))
if (settingsState.value.enableChanger && it) {
if (settingsState.value.enableChanger) {
job?.cancel()
job = scope.launch {
delay(1000)
Expand All @@ -691,7 +690,7 @@ fun PaperizeApp(
},
onVignetteChange = {
settingsViewModel.onEvent(SettingsEvent.SetVignette(it))
if (settingsState.value.enableChanger && it) {
if (settingsState.value.enableChanger) {
job?.cancel()
job = scope.launch {
delay(1000)
Expand Down Expand Up @@ -896,7 +895,6 @@ fun PaperizeApp(
) {
SettingsScreen(
settingsState = settingsViewModel.state,
topInsets = topInsets,
onBackClick = { navController.navigateUp() },
onDarkModeClick = {
settingsViewModel.onEvent(SettingsEvent.SetDarkMode(it))
Expand All @@ -916,6 +914,9 @@ fun PaperizeApp(
onLicenseClick = {
navController.navigate(Licenses)
},
onContactClick = {
SendContactIntent(context)
},
onResetClick = {
settingsViewModel.onEvent(SettingsEvent.Reset)
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset())
Expand Down Expand Up @@ -954,7 +955,6 @@ fun PaperizeApp(
}
) {
PrivacyScreen(
topInsets = topInsets,
onBackClick = { navController.navigateUp() },
)
}
Expand Down Expand Up @@ -982,8 +982,7 @@ fun PaperizeApp(
}
) {
LicensesScreen(
topInsets = topInsets,
onBackClick = { navController.navigateUp() },
onBackClick = { navController.navigateUp() }
)
}
}
Expand Down
Loading

0 comments on commit 7f32f76

Please sign in to comment.