1fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn/*
2fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn * Copyright (C) 2011 The Android Open Source Project
3fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn *
4fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn * Licensed under the Apache License, Version 2.0 (the "License");
5fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn * you may not use this file except in compliance with the License.
6fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn * You may obtain a copy of the License at
7fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn *
8fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn *      http://www.apache.org/licenses/LICENSE-2.0
9fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn *
10fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn * Unless required by applicable law or agreed to in writing, software
11fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn * distributed under the License is distributed on an "AS IS" BASIS,
12fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn * See the License for the specific language governing permissions and
14fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn * limitations under the License.
15fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn */
16fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn
17fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackbornpackage com.android.settings;
18fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn
19fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackbornimport android.app.AlertDialog.Builder;
20fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackbornimport android.content.Context;
21fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackbornimport android.content.DialogInterface;
22fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackbornimport android.os.Bundle;
23fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackbornimport android.os.SystemProperties;
24fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackbornimport android.preference.DialogPreference;
25fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackbornimport android.util.AttributeSet;
26fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackbornimport android.view.View;
27fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn
28fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackbornpublic class BugreportPreference extends DialogPreference {
29fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    public BugreportPreference(Context context, AttributeSet attrs) {
30fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn        super(context, attrs);
31fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    }
32fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn
33fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    @Override
34fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    protected void onPrepareDialogBuilder(Builder builder) {
35fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn        super.onPrepareDialogBuilder(builder);
362d803a3931797891a30158c1a912ce775049f974Dianne Hackborn        builder.setPositiveButton(com.android.internal.R.string.report, this);
372d803a3931797891a30158c1a912ce775049f974Dianne Hackborn        builder.setMessage(com.android.internal.R.string.bugreport_message);
38fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    }
39fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn
40fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    @Override
41fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    protected void showDialog(Bundle state) {
42fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn        super.showDialog(state);
43fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    }
44fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn
45fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    @Override
46fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    protected void onBindDialogView(View view) {
47fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn        super.onBindDialogView(view);
48fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    }
49fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn
50fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    @Override
51fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    protected void onDialogClosed(boolean positiveResult) {
52fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn        super.onDialogClosed(positiveResult);
53fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    }
54fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn
55fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    @Override
56fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    public void onClick(DialogInterface dialog, int which) {
57fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn        if (which == DialogInterface.BUTTON_POSITIVE) {
58fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn            SystemProperties.set("ctl.start", "bugreport");
59fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn        }
60fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn    }
61fd8c315573ffc245c17d549e61c138c8ddba7e06Dianne Hackborn}
62