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.MeasurementActionDelegate; 26 import com.android.adservices.ui.settings.fragments.AdServicesSettingsMeasurementFragment; 27 import com.android.adservices.ui.settings.viewmodels.MeasurementViewModel; 28 29 /** Android application activity provides functionality to control measurement data and consent. */ 30 // TODO(b/269798827): Enable for R. 31 @RequiresApi(Build.VERSION_CODES.S) 32 public class MeasurementActivity extends AdServicesBaseActivity { 33 private MeasurementActionDelegate mActionDelegate; 34 35 /** @return the action delegate for the activity. */ getActionDelegate()36 public MeasurementActionDelegate 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( 47 R.id.fragment_container_view, 48 AdServicesSettingsMeasurementFragment.class, 49 null) 50 .setReorderingAllowed(true) 51 .commit(); 52 initActionDelegate(); 53 } 54 55 @Override initBeta()56 public void initBeta() {} 57 58 @Override initGA()59 public void initGA() {} 60 61 @Override initU18()62 public void initU18() {} 63 initActionDelegate()64 private void initActionDelegate() { 65 mActionDelegate = 66 new MeasurementActionDelegate( 67 this, new ViewModelProvider(this).get(MeasurementViewModel.class)); 68 } 69 } 70