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.fragments; 17 18 import android.os.Build; 19 import android.os.Bundle; 20 import android.view.LayoutInflater; 21 import android.view.View; 22 import android.view.ViewGroup; 23 24 import androidx.annotation.RequiresApi; 25 import androidx.fragment.app.Fragment; 26 27 import com.android.adservices.api.R; 28 import com.android.adservices.ui.settings.activities.MeasurementActivity; 29 import com.android.modules.utils.build.SdkLevel; 30 31 /** Fragment for the Measurement view of the AdServices Settings App. */ 32 // TODO(b/269798827): Enable for R. 33 @RequiresApi(Build.VERSION_CODES.S) 34 public class AdServicesSettingsMeasurementFragment extends Fragment { 35 36 @Override onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)37 public View onCreateView( 38 LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 39 if (SdkLevel.isAtLeastR() && !SdkLevel.isAtLeastS()) { 40 return inflater.inflate(R.layout.measurement_fragment_v30, container, false); 41 } else { 42 return inflater.inflate(R.layout.measurement_fragment, container, false); 43 } 44 } 45 46 @Override onResume()47 public void onResume() { 48 super.onResume(); 49 initActionListeners(); 50 } 51 52 // initialize all action listeners except for actions in Measurement list initActionListeners()53 private void initActionListeners() { 54 ((MeasurementActivity) requireActivity()).getActionDelegate().initMeasurementFragment(this); 55 } 56 } 57