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.NonNull; 25 import androidx.annotation.RequiresApi; 26 import androidx.fragment.app.Fragment; 27 28 import com.android.adservices.api.R; 29 import com.android.adservices.ui.settings.activities.AdServicesSettingsMainActivity; 30 import com.android.adservices.ui.settings.delegates.MainActionDelegate; 31 32 /** Fragment for the main view of the AdServices Settings App. */ 33 // TODO(b/269798827): Enable for R. 34 @RequiresApi(Build.VERSION_CODES.S) 35 public class AdServicesSettingsMainFragment extends Fragment { 36 37 public static final String ERROR_MESSAGE_VIEW_MODEL_EXCEPTION_WHILE_GET_CONSENT = 38 "getConsent method failed. Will not change consent value in view model."; 39 public static final String PRIVACY_SANDBOX_BETA_SWITCH_KEY = "privacy_sandbox_beta_switch"; 40 41 @Override onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)42 public View onCreateView( 43 LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 44 return inflater.inflate(R.layout.main_fragment, container, false); 45 } 46 47 @Override onViewCreated(@onNull View view, Bundle savedInstanceState)48 public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { 49 super.onViewCreated(view, savedInstanceState); 50 } 51 52 @Override onResume()53 public void onResume() { 54 super.onResume(); 55 initActionListeners(); 56 } 57 58 // initialize all action listeners initActionListeners()59 private void initActionListeners() { 60 MainActionDelegate actionDelegate = 61 ((AdServicesSettingsMainActivity) requireActivity()).getActionDelegate(); 62 actionDelegate.initMainFragment(this); 63 // the entry point of Apps, Topics, Measurement should be visible all the time 64 requireView().findViewById(R.id.privacy_sandbox_controls).setVisibility(View.VISIBLE); 65 } 66 } 67