1 /* 2 * Copyright (C) 2015 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.system.development; 18 19 import android.content.Context; 20 import android.os.Bundle; 21 22 import androidx.annotation.Keep; 23 import androidx.annotation.NonNull; 24 import androidx.leanback.app.GuidedStepFragment; 25 import androidx.leanback.widget.GuidanceStylist; 26 import androidx.leanback.widget.GuidedAction; 27 28 import com.android.tv.settings.R; 29 30 import java.util.List; 31 32 @Keep 33 public class OemUnlockDialog extends GuidedStepFragment { 34 35 public interface Callback { onOemUnlockConfirm()36 void onOemUnlockConfirm(); 37 } 38 39 @NonNull 40 @Override onCreateGuidance(Bundle savedInstanceState)41 public GuidanceStylist.Guidance onCreateGuidance(Bundle savedInstanceState) { 42 return new GuidanceStylist.Guidance( 43 getString(R.string.confirm_enable_oem_unlock_title), 44 getString(R.string.confirm_enable_oem_unlock_text), 45 null, 46 null); 47 } 48 49 @Override onCreateActions(@onNull List<GuidedAction> actions, Bundle savedInstanceState)50 public void onCreateActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState) { 51 final Context context = getContext(); 52 actions.add(new GuidedAction.Builder(context) 53 .id(GuidedAction.ACTION_ID_OK) 54 .title(getString(R.string.device_apps_app_management_enable)) 55 .build()); 56 actions.add(new GuidedAction.Builder(context) 57 .clickAction(GuidedAction.ACTION_ID_CANCEL).build()); 58 } 59 60 @Override onGuidedActionClicked(GuidedAction action)61 public void onGuidedActionClicked(GuidedAction action) { 62 if (action.getId() == GuidedAction.ACTION_ID_OK) { 63 ((Callback) getTargetFragment()).onOemUnlockConfirm(); 64 getFragmentManager().popBackStack(); 65 } else { 66 getFragmentManager().popBackStack(); 67 } 68 } 69 } 70