• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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.systemui.wallet.dagger;
18 
19 import android.app.Activity;
20 import android.app.Service;
21 import android.content.Context;
22 import android.service.quickaccesswallet.QuickAccessWalletClient;
23 
24 import com.android.systemui.dagger.SysUISingleton;
25 import com.android.systemui.dagger.qualifiers.Background;
26 import com.android.systemui.qs.QsEventLogger;
27 import com.android.systemui.qs.pipeline.shared.TileSpec;
28 import com.android.systemui.qs.shared.model.TileCategory;
29 import com.android.systemui.qs.tileimpl.QSTileImpl;
30 import com.android.systemui.qs.tiles.QuickAccessWalletTile;
31 import com.android.systemui.qs.tiles.base.shared.model.QSTileConfig;
32 import com.android.systemui.qs.tiles.base.shared.model.QSTilePolicy;
33 import com.android.systemui.qs.tiles.base.shared.model.QSTileUIConfig;
34 import com.android.systemui.res.R;
35 import com.android.systemui.wallet.controller.WalletContextualLocationsService;
36 import com.android.systemui.wallet.ui.WalletActivity;
37 
38 import dagger.Binds;
39 import dagger.Module;
40 import dagger.Provides;
41 import dagger.multibindings.ClassKey;
42 import dagger.multibindings.IntoMap;
43 import dagger.multibindings.StringKey;
44 
45 import java.util.concurrent.Executor;
46 
47 /**
48  * Module for injecting classes in Wallet.
49  */
50 @Module
51 public abstract class WalletModule {
52 
53     public static final String WALLET_TILE_SPEC = "wallet";
54 
55     @Binds
56     @IntoMap
57     @ClassKey(WalletContextualLocationsService.class)
bindWalletContextualLocationsService( WalletContextualLocationsService service)58     abstract Service bindWalletContextualLocationsService(
59         WalletContextualLocationsService service);
60 
61     /** */
62     @Binds
63     @IntoMap
64     @ClassKey(WalletActivity.class)
provideWalletActivity(WalletActivity activity)65     public abstract Activity provideWalletActivity(WalletActivity activity);
66 
67     /** */
68     @SysUISingleton
69     @Provides
provideQuickAccessWalletClient(Context context, @Background Executor bgExecutor)70     public static QuickAccessWalletClient provideQuickAccessWalletClient(Context context,
71             @Background Executor bgExecutor) {
72         return QuickAccessWalletClient.create(context, bgExecutor);
73     }
74 
75     /** */
76     @Binds
77     @IntoMap
78     @StringKey(QuickAccessWalletTile.TILE_SPEC)
bindQuickAccessWalletTile( QuickAccessWalletTile quickAccessWalletTile)79     public abstract QSTileImpl<?> bindQuickAccessWalletTile(
80             QuickAccessWalletTile quickAccessWalletTile);
81 
82     @Provides
83     @IntoMap
84     @StringKey(WALLET_TILE_SPEC)
provideQuickAccessWalletTileConfig(QsEventLogger uiEventLogger)85     public static QSTileConfig provideQuickAccessWalletTileConfig(QsEventLogger uiEventLogger) {
86         TileSpec tileSpec = TileSpec.create(WALLET_TILE_SPEC);
87         return new QSTileConfig(
88                 tileSpec,
89                 new QSTileUIConfig.Resource(
90                         R.drawable.ic_wallet_lockscreen,
91                         R.string.wallet_title
92                 ),
93                 uiEventLogger.getNewInstanceId(),
94                 TileCategory.UTILITIES,
95                 tileSpec.getSpec(),
96                 QSTilePolicy.NoRestrictions.INSTANCE
97         );
98     }
99 }
100