• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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.settings.deviceinfo.firmwareversion;
18 
19 import android.app.AlertDialog;
20 import android.app.Dialog;
21 import android.app.Fragment;
22 import android.app.FragmentManager;
23 import android.os.Bundle;
24 import android.view.LayoutInflater;
25 import android.view.View;
26 import android.widget.TextView;
27 
28 import com.android.internal.logging.nano.MetricsProto;
29 import com.android.settings.R;
30 import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
31 
32 public class FirmwareVersionDialogFragment extends InstrumentedDialogFragment {
33 
34     private static final String TAG = "firmwareVersionDialog";
35 
36     private View mRootView;
37 
show(Fragment host)38     public static void show(Fragment host) {
39         final FragmentManager manager = host.getChildFragmentManager();
40         if (manager.findFragmentByTag(TAG) == null) {
41             final FirmwareVersionDialogFragment dialog = new FirmwareVersionDialogFragment();
42             dialog.show(manager, TAG);
43         }
44     }
45 
46     @Override
getMetricsCategory()47     public int getMetricsCategory() {
48         return MetricsProto.MetricsEvent.DIALOG_FIRMWARE_VERSION;
49     }
50 
51     @Override
onCreateDialog(Bundle savedInstanceState)52     public Dialog onCreateDialog(Bundle savedInstanceState) {
53         final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
54                 .setTitle(R.string.firmware_title)
55                 .setPositiveButton(android.R.string.ok, null /* listener */);
56 
57         mRootView = LayoutInflater.from(getActivity()).inflate(
58                 R.layout.dialog_firmware_version, null /* parent */);
59 
60         initializeControllers();
61 
62         return builder.setView(mRootView).create();
63     }
64 
setText(int viewId, CharSequence text)65     public void setText(int viewId, CharSequence text) {
66         final TextView view = mRootView.findViewById(viewId);
67         if (view != null) {
68             view.setText(text);
69         }
70     }
71 
removeSettingFromScreen(int viewId)72     public void removeSettingFromScreen(int viewId) {
73         final View view = mRootView.findViewById(viewId);
74         if (view != null) {
75             view.setVisibility(View.GONE);
76         }
77     }
78 
registerClickListener(int viewId, View.OnClickListener listener)79     public void registerClickListener(int viewId, View.OnClickListener listener) {
80         final View view = mRootView.findViewById(viewId);
81         if (view != null) {
82             view.setOnClickListener(listener);
83         }
84     }
85 
initializeControllers()86     private void initializeControllers() {
87         new FirmwareVersionDialogController(this).initialize();
88         new SecurityPatchLevelDialogController(this).initialize();
89         new BasebandVersionDialogController(this).initialize();
90         new KernelVersionDialogController(this).initialize();
91         new BuildNumberDialogController(this).initialize();
92     }
93 }
94