• 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.activities;
17 
18 import android.os.Build;
19 import android.os.Bundle;
20 import android.view.MenuItem;
21 
22 import androidx.annotation.RequiresApi;
23 import androidx.core.view.WindowCompat;
24 
25 import com.android.adservices.service.FlagsFactory;
26 import com.android.adservices.ui.ModeSelector;
27 import com.android.adservices.ui.OTAResourcesManager;
28 import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
29 
30 /**
31  * Android application activity for controlling settings related to PP (Privacy Preserving) APIs.
32  * This class is the base class for all other activities. We need an activity for each page in order
33  * for {@link CollapsingToolbarBaseActivity} to work properly.
34  */
35 // TODO(b/269798827): Enable for R.
36 @RequiresApi(Build.VERSION_CODES.S)
37 public abstract class AdServicesBaseActivity extends CollapsingToolbarBaseActivity
38         implements ModeSelector {
39     @Override
onCreate(Bundle savedInstanceState)40     protected void onCreate(Bundle savedInstanceState) {
41         super.onCreate(savedInstanceState);
42         WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
43         if (FlagsFactory.getFlags().getUiOtaStringsFeatureEnabled()) {
44             OTAResourcesManager.applyOTAResources(getApplicationContext(), false);
45         }
46         if (FlagsFactory.getFlags().getU18UxEnabled()) {
47             initWithMode(/* should refresh UI */ false);
48         }
49     }
50 
51     @Override
onOptionsItemSelected(MenuItem item)52     public boolean onOptionsItemSelected(MenuItem item) {
53         if (item.getItemId() == android.R.id.home) {
54             onBackPressed();
55             return true;
56         }
57         return super.onOptionsItemSelected(item);
58     }
59 }
60