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

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

Customizable lock screen affordance entry-point.

Adds an entry-point from the wallpaper picker to a fragment that's
dedicated to show the quick affordance picker. The fragment is currently
just blank.

Bug: 254858701
Test: https://screenshot.googleplex.com/txXtXu86w59HcMB - it shows the
names and icons of the selected affordances correctly and clicking it navigates to
the empty page/fragment

Change-Id: I2487f58aa806333ecf780a607abb7851e63a35e8
parent 808fa678
Loading
Loading
Loading
Loading
+75 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2022 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<com.android.customization.picker.quickaffordance.ui.view.KeyguardQuickAffordanceSectionView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?selectableItemBackground"
    android:clickable="true"
    android:paddingVertical="@dimen/section_top_padding"
    android:paddingHorizontal="@dimen/section_horizontal_padding"
    android:orientation="horizontal">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/keyguard_quick_affordance_title"
            style="@style/SectionTitleTextStyle" />

        <TextView
            android:id="@+id/keyguard_quick_affordance_description"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            style="@style/SectionSubtitleTextStyle"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="@dimen/option_tile_width"
        android:layout_height="@dimen/option_tile_width"
        android:orientation="horizontal"
        android:background="@drawable/option_border_color"
        android:importantForAccessibility="noHideDescendants"
        android:gravity="center">

        <ImageView
            android:id="@+id/icon_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="gone" />

        <View
            android:id="@+id/icon_spacer"
            android:layout_width="14dp"
            android:layout_height="0dp"
            android:visibility="gone" />

        <ImageView
            android:id="@+id/icon_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="gone" />

    </LinearLayout>


</com.android.customization.picker.quickaffordance.ui.view.KeyguardQuickAffordanceSectionView>
 No newline at end of file
+24 −0
Original line number Diff line number Diff line
@@ -313,4 +313,28 @@
    [CHAR LIMIT=10].
    -->
    <string name="keyguard_affordance_enablement_dialog_dismiss_button">Done</string>

    <!--
    Label for a menu item on a settings screen that helps the user open a new screen where they can
    configure the lock screen shortcut buttons that appear on the device without unlocking.
    [CHAR LIMIT=16].
    -->
    <string name="keyguard_quick_affordance_title">Shortcuts</string>

    <!--
    Template for text that shows the names of two currently-selected lock screen shortcuts on the
    lock screen. For example, it may say "Camera, Wallet", if the first selected shortcut opens the
    camera app and the second one opens the tap-to-pay wallet experience.
    [CHAR LIMIT=60].
    -->
    <string name="keyguard_quick_affordance_two_selected_template"><xliff:g id="first">%1$s</xliff:g>, <xliff:g id="second">%2$s</xliff:g></string>

    <!--
    Placeholder text that shows when no lock screen shortcuts are currently selected on the lock
    screen. When selected, "None" is replaced by another string that shows what is currently
    selected. For example, it may say "Camera, Wallet", if the first selected shortcut opens the
    camera app and the second one opens the tap-to-pay wallet experience.
    [CHAR LIMIT=60].
    -->
    <string name="keyguard_quick_affordance_none_selected">None</string>
</resources>
+8 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import androidx.fragment.app.FragmentActivity;
import com.android.customization.model.theme.OverlayManagerCompat;
import com.android.customization.model.theme.ThemeBundleProvider;
import com.android.customization.model.theme.ThemeManager;
import com.android.customization.picker.quickaffordance.domain.interactor.KeyguardQuickAffordancePickerInteractor;
import com.android.wallpaper.module.Injector;

public interface CustomizationInjector extends Injector {
@@ -30,4 +31,11 @@ public interface CustomizationInjector extends Injector {

    ThemeManager getThemeManager(ThemeBundleProvider provider, FragmentActivity activity,
            OverlayManagerCompat overlayManagerCompat, ThemesUserEventLogger logger);


    /**
     * Get {@link KeyguardQuickAffordancePickerInteractor}
     */
    KeyguardQuickAffordancePickerInteractor getKeyguardQuickAffordancePickerInteractor(
            Context context);
}
+7 −4
Original line number Diff line number Diff line
package com.android.customization.module;

import android.app.Activity;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.LifecycleOwner;

import com.android.customization.model.color.ColorSectionController;
@@ -28,9 +28,12 @@ import java.util.List;
public final class DefaultCustomizationSections implements CustomizationSections {

    @Override
    public List<CustomizationSectionController<?>> getAllSectionControllers(Activity activity,
            LifecycleOwner lifecycleOwner, WallpaperColorsViewModel wallpaperColorsViewModel,
            WorkspaceViewModel workspaceViewModel, PermissionRequester permissionRequester,
    public List<CustomizationSectionController<?>> getAllSectionControllers(
            FragmentActivity activity,
            LifecycleOwner lifecycleOwner,
            WallpaperColorsViewModel wallpaperColorsViewModel,
            WorkspaceViewModel workspaceViewModel,
            PermissionRequester permissionRequester,
            WallpaperPreviewNavigator wallpaperPreviewNavigator,
            CustomizationSectionNavigationController sectionNavigationController,
            @Nullable Bundle savedInstanceState) {
+39 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.wallpaper.picker.PreviewFragment.ARG_TESTING_MODE_ENAB
import static com.android.wallpaper.picker.PreviewFragment.ARG_VIEW_AS_HOME;
import static com.android.wallpaper.picker.PreviewFragment.ARG_WALLPAPER;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -32,6 +33,11 @@ import androidx.fragment.app.FragmentActivity;
import com.android.customization.model.theme.OverlayManagerCompat;
import com.android.customization.model.theme.ThemeBundleProvider;
import com.android.customization.model.theme.ThemeManager;
import com.android.customization.picker.quickaffordance.data.repository.KeyguardQuickAffordancePickerRepository;
import com.android.customization.picker.quickaffordance.domain.interactor.KeyguardQuickAffordancePickerInteractor;
import com.android.customization.picker.quickaffordance.ui.viewmodel.KeyguardQuickAffordancePickerViewModel;
import com.android.systemui.shared.quickaffordance.data.content.KeyguardQuickAffordanceProviderClient;
import com.android.systemui.shared.quickaffordance.data.content.KeyguardQuickAffordanceProviderClientImpl;
import com.android.wallpaper.model.LiveWallpaperInfo;
import com.android.wallpaper.model.WallpaperInfo;
import com.android.wallpaper.module.CustomizationSections;
@@ -42,6 +48,8 @@ import com.android.wallpaper.picker.ImagePreviewFragment;
import com.android.wallpaper.picker.LivePreviewFragment;
import com.android.wallpaper.picker.PreviewFragment;

import kotlinx.coroutines.Dispatchers;

/**
 * A concrete, real implementation of the dependency provider.
 */
@@ -50,9 +58,12 @@ public class ThemePickerInjector extends WallpaperPicker2Injector
    private CustomizationSections mCustomizationSections;
    private ThemesUserEventLogger mUserEventLogger;
    private WallpaperPreferences mPrefs;
    private KeyguardQuickAffordancePickerInteractor mKeyguardQuickAffordancePickerInteractor;
    private KeyguardQuickAffordancePickerViewModel.Factory
            mKeyguardQuickAffordancePickerViewModelFactory;

    @Override
    public CustomizationSections getCustomizationSections() {
    public CustomizationSections getCustomizationSections(Activity activity) {
        if (mCustomizationSections == null) {
            mCustomizationSections = new DefaultCustomizationSections();
        }
@@ -122,4 +133,31 @@ public class ThemePickerInjector extends WallpaperPicker2Injector
            OverlayManagerCompat overlayManagerCompat, ThemesUserEventLogger logger) {
        return new ThemeManager(provider, activity, overlayManagerCompat, logger);
    }

    @Override
    public KeyguardQuickAffordancePickerInteractor getKeyguardQuickAffordancePickerInteractor(
            Context context) {
        if (mKeyguardQuickAffordancePickerInteractor == null) {
            final KeyguardQuickAffordanceProviderClient client =
                    new KeyguardQuickAffordanceProviderClientImpl(context, Dispatchers.getIO());
            mKeyguardQuickAffordancePickerInteractor = new KeyguardQuickAffordancePickerInteractor(
                    new KeyguardQuickAffordancePickerRepository(client, Dispatchers.getIO()),
                    client);
        }
        return mKeyguardQuickAffordancePickerInteractor;
    }

    /**
     * Returns a {@link KeyguardQuickAffordancePickerViewModel.Factory}.
     */
    public KeyguardQuickAffordancePickerViewModel.Factory
            getKeyguardQuickAffordancePickerViewModelFactory(Context context) {
        if (mKeyguardQuickAffordancePickerViewModelFactory == null) {
            mKeyguardQuickAffordancePickerViewModelFactory =
                    new KeyguardQuickAffordancePickerViewModel.Factory(
                            context,
                            getKeyguardQuickAffordancePickerInteractor(context));
        }
        return mKeyguardQuickAffordancePickerViewModelFactory;
    }
}
Loading