Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a7fab119 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

More actionable reenablement dialogs for quick affordances.

- Ability to pass a full actionIntent instead of just packageName/action
- Generic function to open the Play Store to the releveant app page,
  configurable by OEMs
- Changes to the Home (device controls) lock screen shortcut to take
  advantage of the above

Fix: 281018063
Test: unit tests expanded/added
Test: manually verified that the dialog shows an "install app" action
button that leads to the Play Store and that, when installed, the option
turns enabled.
Test: manually verified that, when not configured, the dialog shows a
"done" button instead of "install app". Once the app is installed
(separately), the action button opens the device control activity.

Change-Id: I23409d1617dce46c822d87da225849656d2f1141
parent f89c4b42
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -913,8 +913,9 @@
                  android:excludeFromRecents="true"
                  android:launchMode="singleInstance"
                  android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden"
                  android:visibleToInstantApps="true">
        </activity>
                  android:visibleToInstantApps="true"
                  android:exported="true"
                  />

        <activity android:name=".controls.management.ControlsEditingActivity"
                  android:label="@string/controls_menu_edit"
@@ -947,8 +948,9 @@
                  android:finishOnTaskLaunch="true"
                  android:launchMode="singleInstance"
                  android:configChanges="screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|orientation"
                  android:visibleToInstantApps="true">
        </activity>
                  android:visibleToInstantApps="true"
                  android:exported="true"
                  />

        <activity android:name=".wallet.ui.WalletActivity"
                  android:label="@string/wallet_title"
+18 −13
Original line number Diff line number Diff line
@@ -163,15 +163,14 @@ interface CustomizationProviderClient {
         */
        val enablementActionText: String? = null,
        /**
         * If the affordance is disabled, this is a "component name" of the format
         * `packageName/action` to be used as an `Intent` for `startActivity` when the action button
         * (shown together with the set of instruction messages when the disabled affordance is
         * selected) is clicked by the user. The button should help send the user to a flow that
         * would help them achieve the instructions and re-enable this affordance.
         * If the affordance is disabled, this is an [Intent] to be used with `startActivity` when
         * the action button (shown together with the set of instruction messages when the disabled
         * affordance is selected) is clicked by the user. The button should help send the user to a
         * flow that would help them achieve the instructions and re-enable this affordance.
         *
         * If `null`, the button should not be shown.
         */
        val enablementActionComponentName: String? = null,
        val enablementActionIntent: Intent? = null,
        /** Optional [Intent] to use to start an activity to configure this affordance. */
        val configureIntent: Intent? = null,
    )
@@ -337,10 +336,10 @@ class CustomizationProviderClientImpl(
                                Contract.LockScreenQuickAffordances.AffordanceTable.Columns
                                    .ENABLEMENT_ACTION_TEXT
                            )
                        val enablementComponentNameColumnIndex =
                        val enablementActionIntentColumnIndex =
                            cursor.getColumnIndex(
                                Contract.LockScreenQuickAffordances.AffordanceTable.Columns
                                    .ENABLEMENT_COMPONENT_NAME
                                    .ENABLEMENT_ACTION_INTENT
                            )
                        val configureIntentColumnIndex =
                            cursor.getColumnIndex(
@@ -354,7 +353,7 @@ class CustomizationProviderClientImpl(
                                isEnabledColumnIndex == -1 ||
                                enablementInstructionsColumnIndex == -1 ||
                                enablementActionTextColumnIndex == -1 ||
                                enablementComponentNameColumnIndex == -1 ||
                                enablementActionIntentColumnIndex == -1 ||
                                configureIntentColumnIndex == -1
                        ) {
                            return@buildList
@@ -377,12 +376,18 @@ class CustomizationProviderClientImpl(
                                            ),
                                    enablementActionText =
                                        cursor.getString(enablementActionTextColumnIndex),
                                    enablementActionComponentName =
                                        cursor.getString(enablementComponentNameColumnIndex),
                                    enablementActionIntent =
                                        cursor
                                            .getString(enablementActionIntentColumnIndex)
                                            ?.toIntent(
                                                affordanceId = affordanceId,
                                            ),
                                    configureIntent =
                                        cursor
                                            .getString(configureIntentColumnIndex)
                                            ?.toIntent(affordanceId = affordanceId),
                                            ?.toIntent(
                                                affordanceId = affordanceId,
                                            ),
                                )
                            )
                        }
@@ -524,7 +529,7 @@ class CustomizationProviderClientImpl(
        affordanceId: String,
    ): Intent? {
        return try {
            Intent.parseUri(this, 0)
            Intent.parseUri(this, Intent.URI_INTENT_SCHEME)
        } catch (e: URISyntaxException) {
            Log.w(TAG, "Cannot parse Uri into Intent for affordance with ID \"$affordanceId\"!")
            null
+4 −5
Original line number Diff line number Diff line
@@ -82,7 +82,6 @@ object CustomizationProviderContract {
            val URI: Uri =
                LOCK_SCREEN_QUICK_AFFORDANCE_BASE_URI.buildUpon().appendPath(TABLE_NAME).build()
            const val ENABLEMENT_INSTRUCTIONS_DELIMITER = "]["
            const val COMPONENT_NAME_SEPARATOR = "/"

            object Columns {
                /** String. Unique ID for this affordance. */
@@ -108,11 +107,11 @@ object CustomizationProviderContract {
                 */
                const val ENABLEMENT_ACTION_TEXT = "enablement_action_text"
                /**
                 * String. Optional package name and activity action string, delimited by
                 * [COMPONENT_NAME_SEPARATOR] to use with an `Intent` to start an activity that
                 * opens a destination where the user can re-enable the disabled affordance.
                 * String. Optional URI-formatted `Intent` (formatted using
                 * `Intent#toUri(Intent.URI_INTENT_SCHEME)` used to start an activity that opens a
                 * destination where the user can re-enable the disabled affordance.
                 */
                const val ENABLEMENT_COMPONENT_NAME = "enablement_action_intent"
                const val ENABLEMENT_ACTION_INTENT = "enablement_action_intent"
                /**
                 * Byte array. Optional parcelled `Intent` to use to start an activity that can be
                 * used to configure the affordance.
+12 −0
Original line number Diff line number Diff line
@@ -902,4 +902,16 @@
    <!-- Time (in ms) to delay the bouncer views from showing when passive auth may be used for
    device entry. -->
    <integer name="primary_bouncer_passive_auth_delay">500</integer>

    <!--
    The package name of the app store app. If empty, features using this should be gracefully
    disabled.
    -->
    <string name="config_appStorePackageName" translatable="false"></string>

    <!-- Template for a link that leads to an app page in the relevant app store. If empty,
    features using this should be gracefully disabled. If not empty, it must include a
    "$packageName" part that will be replaced by the code with the package name of the target app.
    -->
    <string name="config_appStoreAppLinkTemplate" translatable="false"></string>
</resources>
+7 −0
Original line number Diff line number Diff line
@@ -3153,4 +3153,11 @@

    <!--- Content of toast triggered when the notes app entry point is triggered without setting a default notes app. [CHAR LIMIT=NONE] -->
    <string name="set_default_notes_app_toast_content">Set default notes app in Settings</string>

    <!--
    Label for a button that, when clicked, sends the user to the app store to install an app.

    [CHAR LIMIT=64].
    -->
    <string name="install_app">Install app</string>
</resources>
Loading