1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.intentresolver.contentpreview.payloadtoggle.domain.intent
18 
19 import android.app.ActivityOptions
20 import android.app.PendingIntent
21 import android.content.Context
22 import com.android.intentresolver.R
23 import dagger.Binds
24 import dagger.Module
25 import dagger.hilt.InstallIn
26 import dagger.hilt.android.qualifiers.ApplicationContext
27 import dagger.hilt.components.SingletonComponent
28 import javax.inject.Inject
29 import javax.inject.Qualifier
30 
31 /** [PendingIntentSender] for Shareousel custom actions. */
32 class CustomActionPendingIntentSender
33 @Inject
34 constructor(
35     @ApplicationContext private val context: Context,
36 ) : PendingIntentSender {
sendnull37     override fun send(pendingIntent: PendingIntent) {
38         pendingIntent.send(
39             /* context = */ null,
40             /* code = */ 0,
41             /* intent = */ null,
42             /* onFinished = */ null,
43             /* handler = */ null,
44             /* requiredPermission = */ null,
45             /* options = */ ActivityOptions.makeCustomAnimation(
46                     context,
47                     R.anim.slide_in_right,
48                     R.anim.slide_out_left,
49                 )
50                 .toBundle()
51         )
52     }
53 
54     @Module
55     @InstallIn(SingletonComponent::class)
56     interface Binding {
57         @Binds
58         @CustomAction
bindSendernull59         fun bindSender(sender: CustomActionPendingIntentSender): PendingIntentSender
60     }
61 }
62 
63 /** [PendingIntentSender] for Shareousel custom actions. */
64 @Qualifier @MustBeDocumented @Retention(AnnotationRetention.RUNTIME) annotation class CustomAction
65