Skip to content

Commit a022c0c

Browse files
committed
Bump to v1.5
1 parent e94bb71 commit a022c0c

File tree

5 files changed

+134
-21
lines changed

5 files changed

+134
-21
lines changed

app/release/app-release.apk

2.08 MB
Binary file not shown.

app/release/output-metadata.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"version": 3,
3+
"artifactType": {
4+
"type": "APK",
5+
"kind": "Directory"
6+
},
7+
"applicationId": "dev.pranav.applock",
8+
"variantName": "release",
9+
"elements": [
10+
{
11+
"type": "SINGLE",
12+
"filters": [],
13+
"attributes": [],
14+
"versionCode": 7,
15+
"versionName": "1.5",
16+
"outputFile": "app-release.apk"
17+
}
18+
],
19+
"elementType": "File",
20+
"baselineProfiles": [
21+
{
22+
"minApi": 28,
23+
"maxApi": 30,
24+
"baselineProfiles": [
25+
"baselineProfiles/1/app-release.dm"
26+
]
27+
},
28+
{
29+
"minApi": 31,
30+
"maxApi": 2147483647,
31+
"baselineProfiles": [
32+
"baselineProfiles/0/app-release.dm"
33+
]
34+
}
35+
],
36+
"minSdkVersionForDexing": 26
37+
}

app/src/main/java/dev/pranav/applock/data/repository/AppLockRepository.kt

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import dev.pranav.applock.services.ShizukuAppLockService
1616
import rikka.shizuku.Shizuku
1717
import rikka.shizuku.ShizukuProvider
1818

19-
class AppLockRepository(context: Context) {
19+
class AppLockRepository(private val context: Context) {
2020

2121
private val appLockPrefs: SharedPreferences =
2222
context.getSharedPreferences(PREFS_NAME_APP_LOCK, Context.MODE_PRIVATE)
@@ -122,7 +122,7 @@ class AppLockRepository(context: Context) {
122122
)
123123
return try {
124124
BackendImplementation.valueOf(backend ?: BackendImplementation.ACCESSIBILITY.name)
125-
} catch (e: IllegalArgumentException) {
125+
} catch (_: IllegalArgumentException) {
126126
BackendImplementation.ACCESSIBILITY
127127
}
128128
}
@@ -136,7 +136,7 @@ class AppLockRepository(context: Context) {
136136
settingsPrefs.getString(KEY_FALLBACK_BACKEND, BackendImplementation.ACCESSIBILITY.name)
137137
return try {
138138
BackendImplementation.valueOf(fallback ?: BackendImplementation.ACCESSIBILITY.name)
139-
} catch (e: IllegalArgumentException) {
139+
} catch (_: IllegalArgumentException) {
140140
BackendImplementation.ACCESSIBILITY
141141
}
142142
}
@@ -150,6 +150,28 @@ class AppLockRepository(context: Context) {
150150
return activeBackend
151151
}
152152

153+
fun isShowCommunityLink(): Boolean {
154+
return !settingsPrefs.getBoolean(KEY_COMMUNITY_LINK_SHOWN, false)
155+
}
156+
157+
fun setCommunityLinkShown(shown: Boolean) {
158+
settingsPrefs.edit { putBoolean(KEY_COMMUNITY_LINK_SHOWN, shown) }
159+
}
160+
161+
fun isShowDonateLink(): Boolean {
162+
val currentVersionCode =
163+
context.packageManager.getPackageInfo(context.packageName, 0).versionCode
164+
val savedVersionCode = settingsPrefs.getInt(LAST_VERSION_CODE, -1)
165+
166+
if (currentVersionCode > savedVersionCode) {
167+
settingsPrefs.edit {
168+
putInt(LAST_VERSION_CODE, currentVersionCode)
169+
}
170+
return true
171+
}
172+
return false
173+
}
174+
153175
// Backend status checking
154176
fun isBackendAvailable(backend: BackendImplementation, context: Context): Boolean {
155177
return when (backend) {
@@ -163,9 +185,9 @@ class AppLockRepository(context: Context) {
163185
ShizukuProvider.PERMISSION
164186
) == PermissionChecker.PERMISSION_GRANTED
165187
} else {
166-
Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED
188+
Shizuku.pingBinder() && Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED
167189
}
168-
} catch (e: Exception) {
190+
} catch (_: Exception) {
169191
false
170192
}
171193
}
@@ -220,7 +242,7 @@ class AppLockRepository(context: Context) {
220242
Class.forName("dev.pranav.applock.core.monitoring.BackendMonitoringService")
221243
)
222244
context.startService(intent)
223-
} catch (e: Exception) {
245+
} catch (_: Exception) {
224246
// Service class not found or other error, ignore
225247
}
226248
}
@@ -239,7 +261,8 @@ class AppLockRepository(context: Context) {
239261
private const val KEY_UNLOCK_TIME_DURATION = "unlock_time_duration"
240262
private const val KEY_BACKEND_IMPLEMENTATION = "backend_implementation"
241263
private const val KEY_FALLBACK_BACKEND = "fallback_backend"
242-
private const val KEY_ACTIVE_BACKEND = "active_backend"
264+
private const val KEY_COMMUNITY_LINK_SHOWN = "community_link_shown"
265+
private const val LAST_VERSION_CODE = "last_version_code"
243266
private const val KEY_SHIZUKU_EXPERIMENTAL = "shizuku_experimental"
244267

245268

app/src/main/java/dev/pranav/applock/features/applist/ui/MainScreen.kt

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import android.content.pm.ApplicationInfo
88
import android.content.pm.PackageManager
99
import android.util.Log
1010
import android.widget.Toast
11-
import androidx.compose.animation.animateContentSize
12-
import androidx.compose.animation.core.LinearOutSlowInEasing
13-
import androidx.compose.animation.core.tween
1411
import androidx.compose.foundation.Image
1512
import androidx.compose.foundation.clickable
1613
import androidx.compose.foundation.layout.Arrangement
@@ -31,9 +28,11 @@ import androidx.compose.material.icons.Icons
3128
import androidx.compose.material.icons.filled.Search
3229
import androidx.compose.material.icons.filled.Settings
3330
import androidx.compose.material.icons.outlined.Security
31+
import androidx.compose.material3.AlertDialog
3432
import androidx.compose.material3.CircularProgressIndicator
3533
import androidx.compose.material3.ExperimentalMaterial3Api
3634
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
35+
import androidx.compose.material3.FilledTonalButton
3736
import androidx.compose.material3.Icon
3837
import androidx.compose.material3.IconButton
3938
import androidx.compose.material3.MaterialTheme
@@ -44,6 +43,7 @@ import androidx.compose.material3.SearchBarDefaults
4443
import androidx.compose.material3.Surface
4544
import androidx.compose.material3.Switch
4645
import androidx.compose.material3.Text
46+
import androidx.compose.material3.TextButton
4747
import androidx.compose.material3.TopAppBarDefaults
4848
import androidx.compose.runtime.Composable
4949
import androidx.compose.runtime.LaunchedEffect
@@ -64,6 +64,7 @@ import androidx.compose.ui.text.font.FontWeight
6464
import androidx.compose.ui.text.style.TextOverflow
6565
import androidx.compose.ui.unit.dp
6666
import androidx.core.graphics.drawable.toBitmap
67+
import androidx.core.net.toUri
6768
import androidx.lifecycle.viewmodel.compose.viewModel
6869
import androidx.navigation.NavController
6970
import dev.pranav.applock.R
@@ -231,6 +232,65 @@ fun MainScreen(
231232
)
232233
}
233234

235+
val appLockRepository = context.appLockRepository()
236+
237+
var showCommunityLink by remember { mutableStateOf(appLockRepository.isShowCommunityLink()) }
238+
239+
if (showCommunityLink && !showAccessibilityDialog && !showShizukuDialog && !showUsageStatsDialog && !showAntiUninstallAccessibilityDialog && !showAntiUninstallDeviceAdminDialog) {
240+
AlertDialog(
241+
onDismissRequest = { appLockRepository.setCommunityLinkShown(true) },
242+
title = { Text("Join the Community") },
243+
text = { Text("Join our discord community for updates and support.") },
244+
confirmButton = {
245+
TextButton(onClick = {
246+
appLockRepository.setCommunityLinkShown(true)
247+
showCommunityLink = false
248+
context.startActivity(
249+
Intent(
250+
Intent.ACTION_VIEW,
251+
"https://discord.gg/46wCMRVAre".toUri()
252+
)
253+
)
254+
}) {
255+
Text("Join Discord")
256+
}
257+
},
258+
dismissButton = {
259+
TextButton(onClick = { appLockRepository.setCommunityLinkShown(true) }) {
260+
Text("Dismiss")
261+
}
262+
}
263+
)
264+
}
265+
266+
var showDonateDialog by remember { mutableStateOf(appLockRepository.isShowDonateLink()) }
267+
if (showDonateDialog && !showAccessibilityDialog && !showShizukuDialog && !showUsageStatsDialog && !showAntiUninstallAccessibilityDialog && !showAntiUninstallDeviceAdminDialog && !showCommunityLink) {
268+
AlertDialog(
269+
onDismissRequest = { showDonateDialog = false },
270+
title = { Text("Support Development") },
271+
text = { Text("Hi, I'm Pranav, the developer of App Lock. I'm a student developer passionate about creating useful apps. If you find it helpful, please consider supporting its development with a small donation. Any amount is greatly appreciated and helps me continue to improve the app and work on new features. Thank you for your support!") },
272+
confirmButton = {
273+
FilledTonalButton(
274+
onClick = {
275+
context.startActivity(
276+
Intent(
277+
Intent.ACTION_VIEW,
278+
"https://paypal.me/pranavpurwar".toUri()
279+
)
280+
)
281+
showDonateDialog = false
282+
}
283+
) { Text("Donate") }
284+
},
285+
dismissButton = {
286+
TextButton(onClick = {
287+
showDonateDialog = false
288+
}) { Text("Cancel") }
289+
},
290+
containerColor = MaterialTheme.colorScheme.surfaceContainer
291+
)
292+
}
293+
234294
Scaffold(
235295
modifier = Modifier
236296
.fillMaxSize()
@@ -384,13 +444,7 @@ private fun MainContent(
384444
viewModel = viewModel,
385445
onClick = { isChecked ->
386446
onAppToggle(appInfo, isChecked)
387-
},
388-
modifier = Modifier.animateContentSize(
389-
animationSpec = tween(
390-
durationMillis = 300,
391-
easing = LinearOutSlowInEasing
392-
)
393-
)
447+
}
394448
)
395449
}
396450
}
@@ -429,8 +483,7 @@ private fun EmptySearchState(modifier: Modifier = Modifier) {
429483
private fun AppItem(
430484
appInfo: ApplicationInfo,
431485
viewModel: MainViewModel,
432-
onClick: (Boolean) -> Unit,
433-
modifier: Modifier = Modifier
486+
onClick: (Boolean) -> Unit
434487
) {
435488
val context = LocalContext.current
436489
val packageManager = context.packageManager

app/src/main/java/dev/pranav/applock/features/settings/ui/SettingsScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,12 @@ fun SettingsScreen(
455455
HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp))
456456
ActionSettingItem(
457457
icon = Icons.Filled.Person,
458-
title = "Developer Profile",
458+
title = "Join Community",
459459
onClick = {
460460
context.startActivity(
461461
Intent(
462462
Intent.ACTION_VIEW,
463-
"https://github.com/PranavPurwar".toUri()
463+
"https://discord.gg/46wCMRVAre".toUri()
464464
)
465465
)
466466
})

0 commit comments

Comments
 (0)