mirror of
https://github.com/jrpie/Launcher.git
synced 2025-04-19 18:30:50 +02:00
Compare commits
No commits in common. "9f3142cb693a5517068be24c57176f6cf8edf737" and "2fc2b76fbac6b28cb45bb1f8179e1b7f745e49c2" have entirely different histories.
9f3142cb69
...
2fc2b76fba
2 changed files with 9 additions and 13 deletions
|
@ -76,17 +76,6 @@ fun getUserFromId(userId: Int?, context: Context): UserHandle {
|
||||||
return profiles.firstOrNull { it.hashCode() == userId } ?: profiles[0]
|
return profiles.firstOrNull { it.hashCode() == userId } ?: profiles[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getPrivateSpaceUser(context: Context): UserHandle? {
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
val userManager = context.getSystemService(Context.USER_SERVICE) as UserManager
|
|
||||||
val launcherApps = context.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
|
||||||
return userManager.userProfiles.firstOrNull { u ->
|
|
||||||
launcherApps.getLauncherUserInfo(u)?.userType == UserManager.USER_TYPE_PROFILE_PRIVATE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun openInBrowser(url: String, context: Context) {
|
fun openInBrowser(url: String, context: Context) {
|
||||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||||
intent.putExtras(Bundle().apply { putBoolean("new_window", true) })
|
intent.putExtras(Bundle().apply { putBoolean("new_window", true) })
|
||||||
|
|
|
@ -16,7 +16,6 @@ import android.widget.Toast
|
||||||
import de.jrpie.android.launcher.Application
|
import de.jrpie.android.launcher.Application
|
||||||
import de.jrpie.android.launcher.R
|
import de.jrpie.android.launcher.R
|
||||||
import de.jrpie.android.launcher.apps.AppFilter
|
import de.jrpie.android.launcher.apps.AppFilter
|
||||||
import de.jrpie.android.launcher.getPrivateSpaceUser
|
|
||||||
import de.jrpie.android.launcher.isDefaultHomeScreen
|
import de.jrpie.android.launcher.isDefaultHomeScreen
|
||||||
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
||||||
import de.jrpie.android.launcher.ui.list.ListActivity
|
import de.jrpie.android.launcher.ui.list.ListActivity
|
||||||
|
@ -231,7 +230,10 @@ private fun togglePrivateSpaceLock(context: Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val userManager = context.getSystemService(Context.USER_SERVICE) as UserManager
|
val userManager = context.getSystemService(Context.USER_SERVICE) as UserManager
|
||||||
val privateSpaceUser = getPrivateSpaceUser(context)
|
val launcherApps = context.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
||||||
|
val privateSpaceUser = userManager.userProfiles.firstOrNull { u ->
|
||||||
|
launcherApps.getLauncherUserInfo(u)?.userType == UserManager.USER_TYPE_PROFILE_PRIVATE
|
||||||
|
}
|
||||||
if (privateSpaceUser == null) {
|
if (privateSpaceUser == null) {
|
||||||
Toast.makeText(context, context.getString(R.string.toast_private_space_not_available), Toast.LENGTH_LONG).show()
|
Toast.makeText(context, context.getString(R.string.toast_private_space_not_available), Toast.LENGTH_LONG).show()
|
||||||
|
|
||||||
|
@ -247,6 +249,11 @@ private fun togglePrivateSpaceLock(context: Context) {
|
||||||
}
|
}
|
||||||
if (userManager.isQuietModeEnabled(privateSpaceUser)) {
|
if (userManager.isQuietModeEnabled(privateSpaceUser)) {
|
||||||
userManager.requestQuietModeEnabled(false, privateSpaceUser)
|
userManager.requestQuietModeEnabled(false, privateSpaceUser)
|
||||||
|
Toast.makeText(
|
||||||
|
context,
|
||||||
|
context.getString(R.string.toast_private_space_unlocked),
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
).show()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
userManager.requestQuietModeEnabled(true, privateSpaceUser)
|
userManager.requestQuietModeEnabled(true, privateSpaceUser)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue