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 android.os.Build; 19 import android.os.Bundle; 20 21 import androidx.annotation.RequiresApi; 22 import androidx.lifecycle.ViewModelProvider; 23 24 import com.android.adservices.api.R; 25 import com.android.adservices.ui.settings.delegates.BlockedTopicsActionDelegate; 26 import com.android.adservices.ui.settings.fragments.AdServicesSettingsBlockedTopicsFragment; 27 import com.android.adservices.ui.settings.viewmodels.BlockedTopicsViewModel; 28 29 /** 30 * Android application activity for controlling blocked topics that were generated from Topics API. 31 */ 32 // TODO(b/269798827): Enable for R. 33 @RequiresApi(Build.VERSION_CODES.S) 34 public class BlockedTopicsActivity extends AdServicesBaseActivity { 35 private BlockedTopicsActionDelegate mActionDelegate; 36 37 /** @return the action delegate for the activity. */ getActionDelegate()38 public BlockedTopicsActionDelegate getActionDelegate() { 39 return mActionDelegate; 40 } 41 42 @Override onCreate(Bundle savedInstanceState)43 protected void onCreate(Bundle savedInstanceState) { 44 super.onCreate(savedInstanceState); 45 setContentView(R.layout.adservices_settings_main_activity); 46 getSupportFragmentManager() 47 .beginTransaction() 48 .replace( 49 R.id.fragment_container_view, 50 AdServicesSettingsBlockedTopicsFragment.class, 51 null) 52 .setReorderingAllowed(true) 53 .commit(); 54 initActionDelegate(); 55 } 56 57 @Override initBeta()58 public void initBeta() {} 59 60 @Override initGA()61 public void initGA() {} 62 63 @Override initU18()64 public void initU18() {} 65 initActionDelegate()66 private void initActionDelegate() { 67 mActionDelegate = 68 new BlockedTopicsActionDelegate( 69 this, new ViewModelProvider(this).get(BlockedTopicsViewModel.class)); 70 } 71 } 72