• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 @RequiresApi(Build.VERSION_CODES.S)
34 public class AdServicesSettingsMainFragment extends Fragment {
35 
36     public static final String ERROR_MESSAGE_VIEW_MODEL_EXCEPTION_WHILE_GET_CONSENT =
37             "getConsent method failed. Will not change consent value in view model.";
38     public static final String PRIVACY_SANDBOX_BETA_SWITCH_KEY = "privacy_sandbox_beta_switch";
39 
40     @Override
onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)41     public View onCreateView(
42             LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
43         return inflater.inflate(R.layout.main_fragment, container, false);
44     }
45 
46     @Override
onViewCreated(@onNull View view, Bundle savedInstanceState)47     public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
48         super.onViewCreated(view, savedInstanceState);
49     }
50 
51     @Override
onResume()52     public void onResume() {
53         super.onResume();
54         initActionListeners();
55     }
56 
57     // initialize all action listeners
initActionListeners()58     private void initActionListeners() {
59         MainActionDelegate actionDelegate =
60                 ((AdServicesSettingsMainActivity) requireActivity()).getActionDelegate();
61         actionDelegate.initMainFragment(this);
62         // the entry point of Apps, Topics, Measurement should be visible all the time
63         requireView().findViewById(R.id.privacy_sandbox_controls).setVisibility(View.VISIBLE);
64     }
65 }
66