feat: Basic Generator quick tile
This commit is contained in:
parent
8d1f55b867
commit
9d6a47318b
|
@ -220,6 +220,21 @@
|
||||||
android:value="false" />
|
android:value="false" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name="com.artemchep.keyguard.android.shortcut.GeneratorTileService"
|
||||||
|
android:exported="true"
|
||||||
|
android:icon="@drawable/ic_password"
|
||||||
|
android:label="@string/home_generator_label"
|
||||||
|
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="android.service.quicksettings.ACTIVE_TILE"
|
||||||
|
android:value="false" />
|
||||||
|
</service>
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="${applicationId}.fileProvider"
|
android:authorities="${applicationId}.fileProvider"
|
||||||
|
|
|
@ -51,7 +51,12 @@ class MainActivity : BaseActivity() {
|
||||||
private fun updateDeeplinkFromIntent(intent: Intent) {
|
private fun updateDeeplinkFromIntent(intent: Intent) {
|
||||||
val customFilter = intent.getStringExtra("customFilter")
|
val customFilter = intent.getStringExtra("customFilter")
|
||||||
if (customFilter != null) {
|
if (customFilter != null) {
|
||||||
deeplinkService.put("customFilter", customFilter)
|
deeplinkService.put(DeeplinkService.CUSTOM_FILTER, customFilter)
|
||||||
|
}
|
||||||
|
|
||||||
|
val customHome = intent.getStringExtra("customHome")
|
||||||
|
if (customHome != null) {
|
||||||
|
deeplinkService.put(DeeplinkService.CUSTOM_HOME, customHome)
|
||||||
}
|
}
|
||||||
|
|
||||||
val dta = intent.data
|
val dta = intent.data
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.artemchep.keyguard.android.shortcut
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.PendingIntent
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
|
import android.service.quicksettings.TileService
|
||||||
|
import com.artemchep.keyguard.android.MainActivity
|
||||||
|
|
||||||
|
class GeneratorTileService : TileService() {
|
||||||
|
override fun onClick() {
|
||||||
|
super.onClick()
|
||||||
|
if (isSecure) {
|
||||||
|
// Even tho the keyguard is gonna ask for a password, it's better
|
||||||
|
// if we force the device to be unlocked first.
|
||||||
|
unlockAndRun {
|
||||||
|
startMainActivity()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
startMainActivity()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("StartActivityAndCollapseDeprecated")
|
||||||
|
private fun startMainActivity() {
|
||||||
|
val intent = Intent(this, MainActivity::class.java).apply {
|
||||||
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
putExtra("customHome", "generator")
|
||||||
|
}
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
|
val flags =
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||||
|
val pi = PendingIntent.getActivity(
|
||||||
|
this,
|
||||||
|
13214,
|
||||||
|
intent,
|
||||||
|
flags,
|
||||||
|
)
|
||||||
|
startActivityAndCollapse(pi)
|
||||||
|
} else {
|
||||||
|
startActivityAndCollapse(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M80,760L80,680L880,680L880,760L80,760ZM126,518L74,488L108,428L40,428L40,368L108,368L74,310L126,280L160,338L194,280L246,310L212,368L280,368L280,428L212,428L246,488L194,518L160,458L126,518ZM446,518L394,488L428,428L360,428L360,368L428,368L394,310L446,280L480,338L514,280L566,310L532,368L600,368L600,428L532,428L566,488L514,518L480,458L446,518ZM766,518L714,488L748,428L680,428L680,368L748,368L714,310L766,280L800,338L834,280L886,310L852,368L920,368L920,428L852,428L886,488L834,518L800,458L766,518Z"/>
|
||||||
|
</vector>
|
|
@ -3,6 +3,11 @@ package com.artemchep.keyguard.common.service.deeplink
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
interface DeeplinkService {
|
interface DeeplinkService {
|
||||||
|
companion object {
|
||||||
|
const val CUSTOM_FILTER = "customFilter"
|
||||||
|
const val CUSTOM_HOME = "customHome"
|
||||||
|
}
|
||||||
|
|
||||||
fun get(key: String): String?
|
fun get(key: String): String?
|
||||||
|
|
||||||
fun getFlow(key: String): Flow<String?>
|
fun getFlow(key: String): Flow<String?>
|
||||||
|
|
|
@ -88,6 +88,7 @@ import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.compose.ui.zIndex
|
import androidx.compose.ui.zIndex
|
||||||
import com.artemchep.keyguard.common.model.DAccountStatus
|
import com.artemchep.keyguard.common.model.DAccountStatus
|
||||||
|
import com.artemchep.keyguard.common.service.deeplink.DeeplinkService
|
||||||
import com.artemchep.keyguard.common.usecase.GetAccountStatus
|
import com.artemchep.keyguard.common.usecase.GetAccountStatus
|
||||||
import com.artemchep.keyguard.common.usecase.GetNavLabel
|
import com.artemchep.keyguard.common.usecase.GetNavLabel
|
||||||
import com.artemchep.keyguard.feature.generator.GeneratorRoute
|
import com.artemchep.keyguard.feature.generator.GeneratorRoute
|
||||||
|
@ -149,13 +150,28 @@ private val vaultRoute = VaultRoute(
|
||||||
|
|
||||||
private val sendsRoute = SendRoute()
|
private val sendsRoute = SendRoute()
|
||||||
|
|
||||||
|
private val generatorRoute = GeneratorRoute(
|
||||||
|
args = GeneratorRoute.Args(
|
||||||
|
password = true,
|
||||||
|
username = true,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
private val watchtowerRoute = WatchtowerRoute()
|
private val watchtowerRoute = WatchtowerRoute()
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HomeScreen(
|
fun HomeScreen(
|
||||||
defaultRoute: Route = vaultRoute,
|
|
||||||
navBarVisible: Boolean = true,
|
navBarVisible: Boolean = true,
|
||||||
) {
|
) {
|
||||||
|
val deeplinkService by rememberInstance<DeeplinkService>()
|
||||||
|
val defaultRoute = remember {
|
||||||
|
val defaultHome = deeplinkService.get(DeeplinkService.CUSTOM_HOME)
|
||||||
|
when (defaultHome) {
|
||||||
|
"generator" -> generatorRoute
|
||||||
|
else -> vaultRoute
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val navRoutes = remember {
|
val navRoutes = remember {
|
||||||
persistentListOf(
|
persistentListOf(
|
||||||
Rail(
|
Rail(
|
||||||
|
@ -171,12 +187,7 @@ fun HomeScreen(
|
||||||
label = TextHolder.Res(Res.strings.home_send_label),
|
label = TextHolder.Res(Res.strings.home_send_label),
|
||||||
),
|
),
|
||||||
Rail(
|
Rail(
|
||||||
route = GeneratorRoute(
|
route = generatorRoute,
|
||||||
args = GeneratorRoute.Args(
|
|
||||||
password = true,
|
|
||||||
username = true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
icon = Icons.Outlined.Password,
|
icon = Icons.Outlined.Password,
|
||||||
iconSelected = Icons.Filled.Password,
|
iconSelected = Icons.Filled.Password,
|
||||||
label = TextHolder.Res(Res.strings.home_generator_label),
|
label = TextHolder.Res(Res.strings.home_generator_label),
|
||||||
|
|
|
@ -1279,7 +1279,7 @@ fun vaultListScreenState(
|
||||||
.shareIn(this, SharingStarted.WhileSubscribed(), replay = 1)
|
.shareIn(this, SharingStarted.WhileSubscribed(), replay = 1)
|
||||||
|
|
||||||
val deeplinkCustomFilterFlow = if (args.main) {
|
val deeplinkCustomFilterFlow = if (args.main) {
|
||||||
val customFilterKey = "customFilter"
|
val customFilterKey = DeeplinkService.CUSTOM_FILTER
|
||||||
deeplinkService
|
deeplinkService
|
||||||
.getFlow(customFilterKey)
|
.getFlow(customFilterKey)
|
||||||
.filterNotNull()
|
.filterNotNull()
|
||||||
|
|
Loading…
Reference in New Issue