1/*
2 * Copyright (C) 2014 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.rs.imagejb;
18
19import android.app.Activity;
20import android.app.AlertDialog;
21import android.app.DialogFragment;
22import android.app.Dialog;
23import android.content.DialogInterface;
24import android.os.Bundle;
25import android.view.View;
26
27public class IPSettings extends DialogFragment {
28    private boolean[] mEnables;
29    public boolean mOk = false;
30
31    public IPSettings(boolean[] enables) {
32        mEnables = enables;
33    }
34
35    @Override
36    public Dialog onCreateDialog(Bundle savedInstanceState) {
37        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
38        builder.setTitle(R.string.settings);
39
40        // Specify the list array, the items to be selected by default (null for none),
41        // and the listener through which to receive callbacks when items are selected
42        builder.setMultiChoiceItems(R.array.settings_array, mEnables,
43                          new DialogInterface.OnMultiChoiceClickListener() {
44                   @Override
45                   public void onClick(DialogInterface dialog, int which, boolean isChecked) {
46                       mEnables[which] = isChecked;
47                   }
48               });
49
50        // Set the action buttons
51        builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
52                   @Override
53                   public void onClick(DialogInterface dialog, int id) {
54                       mOk = true;
55                   }
56               });
57        builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
58                   @Override
59                   public void onClick(DialogInterface dialog, int id) {
60                   }
61               });
62
63        return builder.create();
64    }
65}
66