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.BlockedTopicsActivityActionDelegate; 28 import com.android.adservices.ui.settings.delegates.BlockedTopicsActionDelegate; 29 import com.android.adservices.ui.settings.fragments.AdServicesSettingsBlockedTopicsFragment; 30 import com.android.adservices.ui.settings.viewmodels.BlockedTopicsViewModel; 31 32 /** 33 * Android application activity for controlling blocked topics that were generated from Topics API. 34 */ 35 @RequiresApi(Build.VERSION_CODES.S) 36 public class BlockedTopicsActivity extends AdServicesBaseActivity { 37 private BlockedTopicsActionDelegate mActionDelegate; 38 39 /** @return the action delegate for the activity. */ getActionDelegate()40 public BlockedTopicsActionDelegate getActionDelegate() { 41 return mActionDelegate; 42 } 43 44 @Override onCreate(Bundle savedInstanceState)45 protected void onCreate(Bundle savedInstanceState) { 46 super.onCreate(savedInstanceState); 47 if (!isUxStatesReady(this)) { 48 initFragment(); 49 } 50 } 51 52 @Override initGA()53 public void initGA() { 54 initActivity(); 55 } 56 57 @Override initU18()58 public void initU18() {} 59 60 @Override initRvc()61 public void initRvc() {} 62 initFragment()63 private void initFragment() { 64 setContentView(R.layout.adservices_settings_main_activity); 65 getSupportFragmentManager() 66 .beginTransaction() 67 .replace( 68 R.id.fragment_container_view, 69 AdServicesSettingsBlockedTopicsFragment.class, 70 null) 71 .setReorderingAllowed(true) 72 .commit(); 73 mActionDelegate = 74 new BlockedTopicsActionDelegate( 75 this, new ViewModelProvider(this).get(BlockedTopicsViewModel.class)); 76 } 77 initActivity()78 private void initActivity() { 79 setContentView(R.layout.blocked_topics_activity); 80 // no need to store since not using 81 new BlockedTopicsActivityActionDelegate( 82 this, new ViewModelProvider(this).get(BlockedTopicsViewModel.class)); 83 } 84 } 85