Skip to content

Commit

Permalink
Merge pull request #3 from Esarve/new_ux
Browse files Browse the repository at this point in the history
Merge Bug fixes
  • Loading branch information
Esarve authored Mar 18, 2023
2 parents 06c87aa + 1919363 commit 5c627b0
Show file tree
Hide file tree
Showing 10 changed files with 374 additions and 271 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
Expand Down
33 changes: 16 additions & 17 deletions app/src/main/java/dev/souravdas/hush/activities/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
package dev.souravdas.hush

import android.app.Activity
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.os.*
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.provider.Settings
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.core.app.NotificationManagerCompat
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import dev.sourav.emptycompose.ui.theme.HushTheme
import dev.souravdas.hush.services.KeepAliveService
import dev.souravdas.hush.activities.UIKit
import dev.souravdas.hush.arch.MainActivityVM
import dev.souravdas.hush.models.InstalledPackageInfo
import dev.souravdas.hush.others.Utils
import dev.souravdas.hush.services.KeepAliveService
import kotlinx.coroutines.launch
import javax.inject.Inject

@AndroidEntryPoint
class MainActivity : ComponentActivity() {

@Inject
lateinit var utils: Utils
private val viewModel: MainActivityVM by viewModels()
private var doubleBackToExitPressedOnce = false

Expand All @@ -35,13 +36,16 @@ class MainActivity : ComponentActivity() {
setContent {
viewModel.getSelectedApp()

HushTheme {
UIKit().MainActivityScreen()
HushTheme() {
UIKit().MainActivityScreen(onNotificationPermissionGet = {
openNotificationAccessSettingsIfNeeded(this)
}, checkNotificationPermission = {
isNotificationListenerEnabled(this)
})
}
}

checkService();
openNotificationAccessSettingsIfNeeded(this)
}

private fun checkService() {
Expand All @@ -61,11 +65,6 @@ class MainActivity : ComponentActivity() {
}

private fun openNotificationAccessSettingsIfNeeded(activity: Activity) {
if (isNotificationListenerEnabled(activity)) {
// Permission is already granted, no need to prompt the user
return
}

// Permission is not granted, prompt the user to grant it
val intent = Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS)
activity.startActivity(intent)
Expand Down
Loading

0 comments on commit 5c627b0

Please sign in to comment.