-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite WifiPermissionsActivity to M3 (#791)
* Extract composables * Extract view model and create preview * Switch to M3 and linting * Optimize imports * Minor changes --------- Co-authored-by: Ricki Hirner <hirner@bitfire.at>
- Loading branch information
Showing
4 changed files
with
288 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/src/main/kotlin/at/bitfire/davdroid/ui/account/WifiPermissionsModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package at.bitfire.davdroid.ui.account | ||
|
||
import android.app.Application | ||
import android.content.IntentFilter | ||
import android.location.LocationManager | ||
import androidx.core.content.getSystemService | ||
import androidx.core.location.LocationManagerCompat | ||
import androidx.lifecycle.ViewModel | ||
import at.bitfire.davdroid.util.broadcastReceiverFlow | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.map | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class WifiPermissionsModel @Inject constructor( | ||
context: Application | ||
): ViewModel() { | ||
|
||
private val locationManager = context.getSystemService<LocationManager>()!! | ||
|
||
val locationEnabled = broadcastReceiverFlow(context, IntentFilter(LocationManager.MODE_CHANGED_ACTION), immediate = true) | ||
.map { LocationManagerCompat.isLocationEnabled(locationManager) } | ||
|
||
} |
Oops, something went wrong.