1 /*
2  * Copyright (C) 2022 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 package com.android.wallpaper.picker;
17 
18 import static com.android.wallpaper.util.ActivityUtils.startActivityForResultSafely;
19 
20 import android.content.Intent;
21 import android.os.Bundle;
22 
23 import androidx.annotation.Nullable;
24 import androidx.fragment.app.FragmentActivity;
25 
26 import com.android.wallpaper.config.BaseFlags;
27 import com.android.wallpaper.module.LargeScreenMultiPanesChecker;
28 import com.android.wallpaper.module.MultiPanesChecker;
29 import com.android.wallpaper.picker.customization.ui.CustomizationPickerActivity2;
30 
31 /**
32  *  Activity to relinquish task identity for multi-pane and prevent launching incorrect base intent
33  *  in non multi-pane.
34  */
35 public class TrampolinePickerActivity extends FragmentActivity {
36 
37     @Override
onCreate(@ullable Bundle savedInstanceState)38     protected void onCreate(@Nullable Bundle savedInstanceState) {
39         super.onCreate(savedInstanceState);
40         trampolineForFormFactors();
41     }
42 
trampolineForFormFactors()43     private void trampolineForFormFactors() {
44         final MultiPanesChecker multiPanesChecker = new LargeScreenMultiPanesChecker();
45         final boolean isNewPickerScreen = BaseFlags.get().isNewPickerUi();
46 
47         Bundle bundle = getIntent().getExtras();
48         bundle = (bundle == null) ? new Bundle() : bundle;
49         if (isNewPickerScreen) {
50             startActivityForResultSafely(
51                     /* activity= */ this,
52                     new Intent(this, CustomizationPickerActivity2.class).putExtras(
53                             bundle),
54                     /* requestCode= */ 0
55             );
56             finish();
57         } else {
58             if (multiPanesChecker.isMultiPanesEnabled(this)) {
59                 startActivityForResultSafely(
60                         /* activity= */ this,
61                         new Intent(this, CustomizationPickerActivity.class).putExtras(
62                                 bundle),
63                         /* requestCode= */ 0
64                 );
65             } else {
66                 startActivityForResultSafely(this,
67                         new Intent(this, PassThroughCustomizationPickerActivity.class).putExtras(
68                                 bundle), /* requestCode= */ 0);
69             }
70             finish();
71         }
72     }
73 }
74 
75