• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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 
17 package com.android.tv.settings.slice;
18 
19 import android.os.Bundle;
20 
21 import androidx.fragment.app.Fragment;
22 
23 import com.android.tv.settings.TvSettingsActivity;
24 import com.android.tv.settings.overlay.FlavorUtils;
25 import com.android.tv.twopanelsettings.slices.SliceFragment;
26 import com.android.tv.twopanelsettings.slices.SlicesConstants;
27 
28 /**
29  * Extend this class to implement slice settings activity.
30  */
31 public class SliceActivity extends TvSettingsActivity {
32     private static final String EXTRA_SLICE_URI = "slice_uri";
33     private static final String EXTRA_STARTUP_VERIFICATION_REQUIRED =
34             "startup_verification_required";
35 
36     /** Provide slice uri */
getSliceUri()37     public String getSliceUri() {
38         return getIntent().getStringExtra(EXTRA_SLICE_URI);
39     }
40 
41     /** Provide slice screen title */
getScreenTitle()42     public String getScreenTitle() {
43         return null;
44     }
45 
46     @Override
createSettingsFragment()47     protected Fragment createSettingsFragment() {
48         Bundle bundle = new Bundle();
49         String sliceUri = getSliceUri();
50         if (sliceUri == null) {
51             return null;
52         }
53         bundle.putString(SlicesConstants.TAG_TARGET_URI, sliceUri);
54         bundle.putString(SlicesConstants.TAG_SCREEN_TITLE, getScreenTitle());
55         return FlavorUtils.getFeatureFactory(this).getSettingsFragmentProvider()
56                 .newSettingsFragment(SliceFragment.class.getName(), bundle);
57     }
58 
59     // The startup verification requirement is assumed unless otherwise specified in the Intent, as
60     // this Activity may be started with "SLICE_SETTINGS" action combined with an URL extra
61     // corresponding to a sensitive settings page such as account settings.
62     @Override
isStartupVerificationRequired()63     protected boolean isStartupVerificationRequired() {
64         return getIntent().getBooleanExtra(EXTRA_STARTUP_VERIFICATION_REQUIRED, true);
65     }
66 }
67