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

Commit 23079c7a authored by Shamali P's avatar Shamali P
Browse files

Add repository interfaces describing the data needs of widget picker.

In future, as rest of host code is refactored, some of these may become
independent modules that widget picker could depend on and some may
end up being internal implementations.

Bug: 408283627
Flag: EXEMPT refactor
Test: Not applicable; interfaces
Change-Id: Ib54ce2e48c8f9c8cb779e41a5c2889c1f26ad6f6
parent cfd4c6a5
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -52,3 +52,20 @@ android_library {
        "src/com/android/widgetpicker/shared/model/WidgetUserProfiles.kt",
    ],
}

android_library {
    name: "widget_picker_data_repositories",
    srcs: [
        "src/com/android/widgetpicker/data/repository/WidgetAppIconsRepository.kt",
        "src/com/android/widgetpicker/data/repository/WidgetPreviewRepository.kt",
        "src/com/android/widgetpicker/data/repository/WidgetRecommendationsRepository.kt",
        "src/com/android/widgetpicker/data/repository/WidgetsRepository.kt",
        "src/com/android/widgetpicker/data/repository/WidgetUsersRepository.kt",
    ],
    static_libs: [
        "widget_picker_shared_data_types",
        "kotlinx_coroutines_android",
        "kotlinx_coroutines",
    ],

}
+30 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.
 */

package com.android.widgetpicker.data.repository

import com.android.widgetpicker.shared.model.WidgetAppIcon
import com.android.widgetpicker.shared.model.WidgetAppId
import kotlinx.coroutines.flow.Flow

/** A repository that provides app icons for the widget picker. */
interface WidgetAppIconsRepository {
    /**
     * Loads and returns app icon (may initially return a low res icon, followed by a high res once
     * available).
     */
    fun getAppIcon(widgetAppId: WidgetAppId): Flow<WidgetAppIcon>
}
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.
 */

package com.android.widgetpicker.data.repository

import com.android.widgetpicker.shared.model.WidgetId
import com.android.widgetpicker.shared.model.WidgetPreview

/** A repository that provides previews for the widgets to be displayed in the widget picker. */
interface WidgetPreviewRepository {
    /** Returns the preview for a widget represented by given [WidgetId]. */
    suspend fun getPreview(widgetId: WidgetId): WidgetPreview
}
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.
 */

package com.android.widgetpicker.data.repository

import com.android.widgetpicker.shared.model.WidgetId

/** A repository of widgets that can be recommended to the users in widget picker. */
interface WidgetRecommendationsRepository {
    /** Returns a list of widgets that can be recommended to the users in the widget picker. */
    suspend fun getRecommendations(): List<WidgetId>
}
+30 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.
 */

package com.android.widgetpicker.data.repository

import com.android.widgetpicker.shared.model.WidgetUserProfileType
import com.android.widgetpicker.shared.model.WidgetUserProfiles
import kotlinx.coroutines.flow.Flow

/**
 * A repository that provides information about user profiles for which widgets need to be shown in
 * the widget picker.
 */
interface WidgetUsersRepository {
    /** Get and listen to the changes in available user profiles. */
    fun observeUsers(types: List<WidgetUserProfileType>): Flow<WidgetUserProfiles>
}
Loading