Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Esarve committed Mar 17, 2023
1 parent dcb3348 commit 1919363
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 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
19 changes: 10 additions & 9 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 Down
28 changes: 11 additions & 17 deletions app/src/main/java/dev/souravdas/hush/activities/UIKit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.MaterialTheme as MD3
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.material.FabPosition
import androidx.compose.material.MaterialTheme
import androidx.compose.material.SwitchColors
import androidx.compose.material.SwitchDefaults
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Done
Expand All @@ -37,10 +33,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand All @@ -51,14 +45,8 @@ import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.core.content.ContextCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.google.accompanist.drawablepainter.rememberDrawablePainter
import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.models.base.rememberSheetState
import com.maxkeppeler.sheets.clock.ClockDialog
import com.maxkeppeler.sheets.clock.models.ClockConfig
import com.maxkeppeler.sheets.clock.models.ClockSelection
import dev.souravdas.hush.HushApp
import dev.souravdas.hush.R
import dev.souravdas.hush.arch.MainActivityVM
Expand All @@ -68,10 +56,10 @@ import dev.souravdas.hush.models.SelectedAppForList
import dev.souravdas.hush.others.Constants
import dev.souravdas.hush.others.HushType
import kotlinx.coroutines.launch
import org.threeten.bp.LocalTime
import timber.log.Timber
import java.text.SimpleDateFormat
import java.util.*
import androidx.compose.material3.MaterialTheme as MD3

/**
* Created by Sourav
Expand Down Expand Up @@ -206,7 +194,14 @@ class UIKit() {
sheetPeekHeight = 56.dp,
topBar = {
TopAppBar(
title = { Text(stringResource(id = R.string.app_name)) }
title = {
Text(
stringResource(id = R.string.app_name),
fontSize = 32.sp,
fontWeight = FontWeight.Medium,
color = MD3.colorScheme.onBackground
)
}
)
},
sheetContent = {
Expand Down Expand Up @@ -394,7 +389,7 @@ class UIKit() {
),
contentDescription = "appIcon",
modifier = Modifier
.size(56.dp)
.size(50.dp)
.clip(CircleShape)
)
Row(
Expand All @@ -421,7 +416,7 @@ class UIKit() {
)
} else {
CustomChip(
title = selectedApp.selectedApp.hushType.toString(),
title = selectedApp.selectedApp.hushType.label,
)
}
}
Expand Down Expand Up @@ -997,7 +992,6 @@ class UIKit() {
}



fun get12HrsFrom24Hrs(inputTime: String): String {
val timeFormat = SimpleDateFormat("hh:mm", Locale.getDefault())
val time = timeFormat.parse(inputTime)
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/dev/souravdas/hush/arch/MainActivityVM.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ class MainActivityVM @Inject constructor(
)
)
}
return packageNames
return packageNames.sortedBy {
it.appName
}
}


Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/dev/souravdas/hush/others/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import java.util.*

class Utils {

fun checkIfAppExpired(selectedApp: SelectedApp):Boolean{
fun isHushActive(selectedApp: SelectedApp):Boolean{
return (System.currentTimeMillis() <= selectedApp.timeUpdated + selectedApp.durationInMinutes!!* 60000)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class KeepAliveService : Service() {

startForeground(FOREGROUND_SERVICE_ID, notification)



return START_STICKY
}

Expand Down

0 comments on commit 1919363

Please sign in to comment.