1 /*
2  * Copyright (C) 2011 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.gallery3d.gadget;
18 
19 import android.app.Activity;
20 import android.content.Intent;
21 import android.os.Bundle;
22 import android.view.View;
23 import android.view.View.OnClickListener;
24 import android.widget.Button;
25 import android.widget.RadioGroup;
26 import android.widget.RadioGroup.OnCheckedChangeListener;
27 
28 import com.android.gallery3d.R;
29 
30 public class WidgetTypeChooser extends Activity {
31 
32     private OnCheckedChangeListener mListener = new OnCheckedChangeListener() {
33         @Override
34         public void onCheckedChanged(RadioGroup group, int checkedId) {
35             Intent data = new Intent()
36                     .putExtra(WidgetConfigure.KEY_WIDGET_TYPE, checkedId);
37             setResult(RESULT_OK, data);
38             finish();
39         }
40     };
41 
42     @Override
onCreate(Bundle savedInstanceState)43     public void onCreate(Bundle savedInstanceState) {
44         super.onCreate(savedInstanceState);
45         setTitle(R.string.widget_type);
46         setContentView(R.layout.choose_widget_type);
47         RadioGroup rg = (RadioGroup) findViewById(R.id.widget_type);
48         rg.setOnCheckedChangeListener(mListener);
49 
50         Button cancel = (Button) findViewById(R.id.cancel);
51         cancel.setOnClickListener(new OnClickListener() {
52             @Override
53             public void onClick(View v) {
54                 setResult(RESULT_CANCELED);
55                 finish();
56             }
57         });
58     }
59 }
60