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