Skip to content

Commit f545209

Browse files
authored
Merge pull request #14 from Esarve/develop
Merge Develop
2 parents 5c627b0 + 9df20ca commit f545209

28 files changed

+1998
-1094
lines changed

app/build.gradle

+20-14
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ android {
1313
applicationId "dev.souravdas.hush"
1414
minSdk 22
1515
targetSdk 33
16-
versionCode 1
17-
versionName "1.0"
16+
versionCode 2
17+
versionName "0.2-alpha"
1818

1919
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2020
vectorDrawables {
@@ -90,23 +90,14 @@ dependencies {
9090
implementation 'androidx.compose.ui:ui-graphics'
9191
implementation 'androidx.compose.ui:ui-tooling-preview'
9292
implementation 'androidx.compose.material3:material3:1.1.0-alpha07'
93-
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
93+
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.0'
9494
implementation 'androidx.activity:activity-compose:1.6.1'
9595
implementation 'androidx.compose.material:material:1.3.1'
9696
testImplementation 'junit:junit:4.13.2'
9797
testImplementation 'junit:junit:4.13.2'
9898
implementation 'com.jakewharton.timber:timber:5.0.1'
9999
implementation 'com.google.accompanist:accompanist-drawablepainter:0.28.0'
100-
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
101-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
102-
androidTestImplementation platform('androidx.compose:compose-bom:2023.01.00')
103-
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
104-
debugImplementation 'androidx.compose.ui:ui-tooling'
105-
debugImplementation 'androidx.compose.ui:ui-test-manifest'
106100
implementation 'com.jakewharton.threetenabp:threetenabp:1.4.4'
107-
implementation "com.maxkeppeler.sheets-compose-dialogs:core:1.1.0"
108-
implementation "com.maxkeppeler.sheets-compose-dialogs:clock:1.1.0"
109-
// implementation "com.maxkeppeler.sheets-compose-dialogs:date_time:1.1.0"
110101

111102
def room_version = "2.5.0"
112103

@@ -122,7 +113,22 @@ dependencies {
122113
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
123114
implementation "androidx.activity:activity-ktx:1.6.1"
124115

125-
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.0-rc01"
126-
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
116+
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.0"
117+
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.0"
118+
119+
def nav_version = "2.5.3"
120+
121+
implementation "androidx.navigation:navigation-compose:$nav_version"
122+
implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
123+
124+
125+
implementation "com.github.bumptech.glide:compose:1.0.0-alpha.1"
126+
127+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
128+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
129+
androidTestImplementation platform('androidx.compose:compose-bom:2023.01.00')
130+
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
131+
debugImplementation 'androidx.compose.ui:ui-tooling'
132+
debugImplementation 'androidx.compose.ui:ui-test-manifest'
127133

128134
}

app/src/main/AndroidManifest.xml

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools">
44

5+
<uses-permission android:name="android.permission.INTERNET" />
6+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
7+
58
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
69
tools:ignore="ProtectedPermissions" />
710
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
@@ -22,7 +25,7 @@
2225
android:hardwareAccelerated="true"
2326
tools:targetApi="31">
2427
<activity
25-
android:name=".MainActivity"
28+
android:name=".activities.MainActivity"
2629
android:exported="true"
2730
android:label="@string/app_name"
2831
android:theme="@style/Theme.Hush">
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package dev.souravdas.hush
1+
package dev.souravdas.hush.activities
22

33
import android.app.Activity
44
import android.content.Context
@@ -14,13 +14,17 @@ import androidx.activity.compose.setContent
1414
import androidx.activity.viewModels
1515
import androidx.core.app.NotificationManagerCompat
1616
import androidx.lifecycle.lifecycleScope
17+
import androidx.navigation.NavHostController
18+
import androidx.navigation.compose.rememberNavController
1719
import dagger.hilt.android.AndroidEntryPoint
1820
import dev.sourav.emptycompose.ui.theme.HushTheme
19-
import dev.souravdas.hush.activities.UIKit
2021
import dev.souravdas.hush.arch.MainActivityVM
22+
import dev.souravdas.hush.nav.NavGraph
23+
import dev.souravdas.hush.nav.Screens
2124
import dev.souravdas.hush.others.Utils
2225
import dev.souravdas.hush.services.KeepAliveService
2326
import kotlinx.coroutines.launch
27+
import timber.log.Timber
2428
import javax.inject.Inject
2529

2630
@AndroidEntryPoint
@@ -30,18 +34,23 @@ class MainActivity : ComponentActivity() {
3034
lateinit var utils: Utils
3135
private val viewModel: MainActivityVM by viewModels()
3236
private var doubleBackToExitPressedOnce = false
37+
private lateinit var navController: NavHostController
3338

3439
override fun onCreate(savedInstanceState: Bundle?) {
3540
super.onCreate(savedInstanceState)
3641
setContent {
3742
viewModel.getSelectedApp()
3843

44+
navController = rememberNavController()
45+
3946
HushTheme() {
40-
UIKit().MainActivityScreen(onNotificationPermissionGet = {
41-
openNotificationAccessSettingsIfNeeded(this)
42-
}, checkNotificationPermission = {
43-
isNotificationListenerEnabled(this)
44-
})
47+
NavGraph(
48+
navController = navController,
49+
onNotificationPermissionGet = {
50+
openNotificationAccessSettingsIfNeeded(this)
51+
}, checkNotificationPermission = {
52+
isNotificationListenerEnabled(this)
53+
})
4554
}
4655
}
4756

@@ -50,14 +59,19 @@ class MainActivity : ComponentActivity() {
5059

5160
private fun checkService() {
5261
lifecycleScope.launch {
53-
viewModel.getHushStatusAsFlow().collect() {value ->
54-
if (value){
62+
viewModel.getHushStatusAsFlow().collect() { value ->
63+
if (value) {
5564
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
56-
startForegroundService(Intent(this@MainActivity, KeepAliveService::class.java))
57-
}else{
65+
startForegroundService(
66+
Intent(
67+
this@MainActivity,
68+
KeepAliveService::class.java
69+
)
70+
)
71+
} else {
5872
startService(Intent(this@MainActivity, KeepAliveService::class.java))
5973
}
60-
}else{
74+
} else {
6175
stopService(Intent(this@MainActivity, KeepAliveService::class.java))
6276
}
6377
}
@@ -76,21 +90,25 @@ class MainActivity : ComponentActivity() {
7690
return enabledPackages.contains(packageName)
7791
}
7892

93+
@Deprecated("Deprecated in Java")
7994
override fun onBackPressed() {
80-
if (doubleBackToExitPressedOnce) {
81-
viewModel.removeIncompleteApp()
82-
finishAffinity()
83-
return
84-
}
95+
if (navController.currentDestination!!.route == Screens.MainScreen.route){
96+
if (doubleBackToExitPressedOnce) {
97+
viewModel.removeIncompleteApp()
98+
finishAffinity()
99+
return
100+
}
85101

86-
this.doubleBackToExitPressedOnce = true
87-
Toast.makeText(this, "Please click BACK again to exit", Toast.LENGTH_SHORT).show()
102+
this.doubleBackToExitPressedOnce = true
103+
Toast.makeText(this, "Please click BACK again to exit", Toast.LENGTH_SHORT).show()
88104

89-
Handler(Looper.getMainLooper()).postDelayed(Runnable { doubleBackToExitPressedOnce = false }, 2000)
105+
Handler(Looper.getMainLooper()).postDelayed(Runnable {
106+
doubleBackToExitPressedOnce = false
107+
}, 2000)
108+
}else{
109+
super.onBackPressed()
110+
}
90111
}
91112

92-
override fun onDestroy() {
93-
super.onDestroy()
94-
}
95113
}
96114

0 commit comments

Comments
 (0)