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.adservices.ui.settings.activities; 17 18 import static com.android.adservices.ui.UxUtil.isUxStatesReady; 19 20 import android.os.Build; 21 import android.os.Bundle; 22 23 import androidx.annotation.RequiresApi; 24 import androidx.lifecycle.ViewModelProvider; 25 26 import com.android.adservices.api.R; 27 import com.android.adservices.ui.settings.activitydelegates.BlockedAppsActivityActionDelegate; 28 import com.android.adservices.ui.settings.delegates.BlockedAppsActionDelegate; 29 import com.android.adservices.ui.settings.fragments.AdServicesSettingsBlockedAppsFragment; 30 import com.android.adservices.ui.settings.viewmodels.BlockedAppsViewModel; 31 32 /** 33 * Android application activity for controlling applications which are blocked from interacting with 34 * FLEDGE (Remarketing) APIs. 35 */ 36 @RequiresApi(Build.VERSION_CODES.S) 37 public class BlockedAppsActivity extends AdServicesBaseActivity { 38 private BlockedAppsActionDelegate mActionDelegate; 39 40 /** @return the action delegate for the activity. */ getActionDelegate()41 public BlockedAppsActionDelegate getActionDelegate() { 42 return mActionDelegate; 43 } 44 45 @Override onCreate(Bundle savedInstanceState)46 protected void onCreate(Bundle savedInstanceState) { 47 super.onCreate(savedInstanceState); 48 if (!isUxStatesReady(this)) { 49 initFragment(); 50 } 51 } 52 53 @Override initGA()54 public void initGA() { 55 initActivity(); 56 } 57 58 @Override initU18()59 public void initU18() {} 60 61 @Override initRvc()62 public void initRvc() {} 63 initFragment()64 private void initFragment() { 65 setContentView(R.layout.adservices_settings_main_activity); 66 getSupportFragmentManager() 67 .beginTransaction() 68 .replace( 69 R.id.fragment_container_view, 70 AdServicesSettingsBlockedAppsFragment.class, 71 null) 72 .setReorderingAllowed(true) 73 .commit(); 74 mActionDelegate = 75 new BlockedAppsActionDelegate( 76 this, new ViewModelProvider(this).get(BlockedAppsViewModel.class)); 77 } 78 initActivity()79 private void initActivity() { 80 setContentView(R.layout.blocked_apps_activity); 81 // no need to store since not using 82 new BlockedAppsActivityActionDelegate( 83 this, new ViewModelProvider(this).get(BlockedAppsViewModel.class)); 84 } 85 } 86