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