Skip to content

Commit

Permalink
Open BmwMine permissions window for Nearby Devices
Browse files Browse the repository at this point in the history
  • Loading branch information
hufman committed Oct 8, 2024
1 parent 10d2a43 commit 7b596c3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.net.Uri
import android.os.Build
import android.provider.Settings
import androidx.core.app.ActivityCompat
import io.bimmergestalt.idriveconnectkit.android.security.KnownSecurityServices
import me.hufman.androidautoidrive.MutableAppSettingsReceiver
import me.hufman.androidautoidrive.music.controllers.SpotifyAppController
import me.hufman.androidautoidrive.music.spotify.SpotifyAuthStateManager
Expand Down Expand Up @@ -68,6 +69,28 @@ class PermissionsController(val activity: Activity) {
openApplicationPermissions(activity.packageName)
}

fun openBmwMinePermissions() {
for (app in KnownSecurityServices.entries) {
try {
if (activity.packageManager.getPackageInfo(app.packageName, 0) != null) {
openApplicationPermissions(app.packageName)
break
}
} catch (_: Exception) {}
}
}

fun openMiniMinePermissions() {
for (app in KnownSecurityServices.entries) {
try {
if (activity.packageManager.getPackageInfo(app.packageName, 0) != null) {
openApplicationPermissions(app.packageName)
break
}
} catch (_: Exception) {}
}
}

fun promptNotification() {
val intent = Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS")
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/layout/fragment_dependencyinfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="@dimen/checkbox_vertical_margin"
android:gravity="center">
android:gravity="center"
android:onClick="@{() -> permissionsController.openBmwMinePermissions()}">

<ImageView
android:layout_width="48dp"
Expand Down Expand Up @@ -404,7 +405,8 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="@dimen/checkbox_vertical_margin"
android:gravity="center">
android:gravity="center"
android:onClick="@{() -> permissionsController.openMiniMinePermissions()}">

<ImageView
android:layout_width="48dp"
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/layout/fragment_dependencysummary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="@dimen/checkbox_vertical_margin"
android:gravity="center">
android:gravity="center"
android:onClick="@{() -> permissionsController.openBmwMinePermissions()}">

<ImageView
android:layout_width="48dp"
Expand Down Expand Up @@ -290,7 +291,8 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="@dimen/checkbox_vertical_margin"
android:gravity="center">
android:gravity="center"
android:onClick="@{() -> permissionsController.openMiniMinePermissions()}">

<ImageView
android:layout_width="48dp"
Expand Down

0 comments on commit 7b596c3

Please sign in to comment.