Implement Smartspacer as an alternative At a Glance provider (#3684)

This commit is contained in:
Kieron Quinn
2023-11-13 09:17:21 +00:00
committed by GitHub
parent da776eee3b
commit d96a511efe
9 changed files with 65 additions and 6 deletions

View File

@@ -19,9 +19,10 @@
** Modifications copyright 2021, Lawnchair
*/
-->
<manifest
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:targetSdkVersion="30" android:minSdkVersion="26"/>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk android:targetSdkVersion="30" android:minSdkVersion="26"
tools:overrideLibrary="com.kieronquinn.app.smartspacer.sdk.client"/>
<!--
Manifest entries specific to Launcher3. This is merged with AndroidManifest-common.xml.
Refer comments around specific entries on how to extend individual components.

View File

@@ -79,7 +79,7 @@ final def ciRunNumber = System.getenv("GITHUB_RUN_NUMBER") ?: ""
final def isReleaseBuild = ciBuild && ciRef.contains("alpha")
final def devReleaseName = ciBuild ? "Dev (#${ciRunNumber})" : "Dev (${buildCommit})"
final def version = "13"
final def releaseName = "Alpha 1"
final def releaseName = "Alpha 4"
final def versionDisplayName = "${version} ${isReleaseBuild ? releaseName : devReleaseName}"
final def majorVersion = versionDisplayName.split("\\.")[0]
@@ -380,6 +380,9 @@ dependencies {
implementation 'com.github.samanzamani:PersianDate:1.7.1'
implementation 'com.airbnb.android:lottie:6.1.0'
// Smartspacer
implementation 'com.kieronquinn.smartspacer:sdk-client:1.0.3'
}
ksp {

View File

@@ -23,6 +23,7 @@
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="com.google.android.apps.nexuslauncher.permission.QSB" />
<uses-permission android:name="com.kieronquinn.app.smartspacer.permission.ACCESS_SMARTSPACER"/>
<permission
android:name="${packageName}.permission.READ_SETTINGS"

View File

@@ -281,6 +281,7 @@
<string name="smartspace_mode_lawnchair">Lawnchair</string>
<string name="smartspace_mode_google">Google</string>
<string name="smartspace_mode_google_search">Google Search</string>
<string name="smartspace_mode_smartspacer">Smartspacer</string>
<!-- DockPreferences -->
<!-- <string name="dock_label" /> -->

View File

@@ -66,6 +66,7 @@ import com.android.launcher3.util.TouchController
import com.android.launcher3.widget.RoundedCornerEnforcement
import com.android.systemui.plugins.shared.LauncherOverlayManager
import com.android.systemui.shared.system.QuickStepContract
import com.kieronquinn.app.smartspacer.sdk.client.SmartspacerClient
import com.patrykmichalik.opto.core.firstBlocking
import com.patrykmichalik.opto.core.onEach
import dev.kdrag0n.monet.theme.ColorScheme
@@ -320,6 +321,8 @@ class LawnchairLauncher : QuickstepLauncher(), LifecycleOwner,
override fun onDestroy() {
super.onDestroy()
lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
// Only actually closes if required, safe to call if not enabled
SmartspacerClient.close()
}
@Suppress("OVERRIDE_DEPRECATION")

View File

@@ -1,6 +1,7 @@
package app.lawnchair.smartspace.model
import android.content.Context
import android.os.Build
import androidx.annotation.LayoutRes
import androidx.annotation.StringRes
import app.lawnchair.util.isPackageInstalledAndEnabled
@@ -15,6 +16,7 @@ sealed class SmartspaceMode(
fun fromString(value: String): SmartspaceMode = when (value) {
"google" -> GoogleSmartspace
"google_search" -> GoogleSearchSmartspace
"smartspacer" -> Smartspacer
else -> LawnchairSmartspace
}
@@ -25,6 +27,7 @@ sealed class SmartspaceMode(
LawnchairSmartspace,
GoogleSmartspace,
GoogleSearchSmartspace,
Smartspacer,
)
}
@@ -59,3 +62,16 @@ object GoogleSmartspace : SmartspaceMode(
override fun isAvailable(context: Context): Boolean =
context.packageManager.isPackageInstalledAndEnabled("com.google.android.googlequicksearchbox")
}
object Smartspacer : SmartspaceMode(
nameResourceId = R.string.smartspace_mode_smartspacer,
layoutResourceId = R.layout.smartspace_smartspacer,
) {
override fun toString(): String = "smartspacer"
override fun isAvailable(context: Context): Boolean {
// Smartspacer requires Android 10+
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q &&
context.packageManager.isPackageInstalledAndEnabled("com.kieronquinn.app.smartspacer")
}
}

3
proguard.pro vendored
View File

@@ -159,3 +159,6 @@
-keep class com.android.** {
*;
}
# Keep Smartspacer's client SDK
-keep class com.kieronquinn.app.smartspacer.sdk.** { *; }

View File

@@ -20,8 +20,12 @@
*/
-->
<manifest
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:targetSdkVersion="33" android:minSdkVersion="26"/>
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk android:targetSdkVersion="33" android:minSdkVersion="26"
tools:overrideLibrary="com.kieronquinn.app.smartspacer.sdk.client"/>
<!--
Manifest entries specific to Launcher3. This is merged with AndroidManifest-common.xml.
Refer comments around specific entries on how to extend individual components.

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<com.kieronquinn.app.smartspacer.sdk.client.views.BcSmartspaceView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bc_smartspace_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/enhanced_smartspace_margin_start_launcher">
<androidx.viewpager.widget.ViewPager
android:id="@+id/smartspace_card_pager"
android:layout_width="match_parent"
android:layout_height="@dimen/enhanced_smartspace_height"
android:layout_marginBottom="@dimen/smartspace_page_margin_16"
android:layout_gravity="center" />
<com.kieronquinn.app.smartspacer.sdk.client.views.PageIndicator
android:id="@+id/smartspace_page_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left|center_vertical|center_horizontal|center|start"
android:importantForAccessibility="no"
android:paddingStart="@dimen/page_indicator_padding_start"
android:paddingTop="@dimen/page_indicator_padding_top_bottom"
android:paddingBottom="@dimen/page_indicator_padding_top_bottom"
android:visibility="visible" />
</com.kieronquinn.app.smartspacer.sdk.client.views.BcSmartspaceView>