1/*
2 * Copyright (C) 2008 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.tests.appwidgethost;
18
19import android.app.Activity;
20import android.content.Intent;
21import android.content.SharedPreferences;
22import android.os.Bundle;
23import android.util.Log;
24import android.view.View;
25import android.widget.EditText;
26
27public class TestAppWidgetConfigure extends Activity {
28    static final String TAG = "TestAppWidgetConfigure";
29
30    public TestAppWidgetConfigure() {
31        super();
32    }
33
34    @Override
35    public void onCreate(Bundle icicle) {
36        super.onCreate(icicle);
37        setContentView(R.layout.test_appwidget_configure);
38
39        findViewById(R.id.save_button).setOnClickListener(mOnClickListener);
40    }
41
42    View.OnClickListener mOnClickListener = new View.OnClickListener() {
43        public void onClick(View v) {
44            String text = ((EditText)findViewById(R.id.edit_text)).getText().toString();
45            Log.d(TAG, "text is '" + text + '\'');
46            SharedPreferences.Editor prefs = getSharedPreferences(TestAppWidgetProvider.PREFS_NAME, 0)
47                    .edit();
48            prefs.putString(TestAppWidgetProvider.PREF_PREFIX_KEY, text);
49            prefs.commit();
50            setResult(RESULT_OK);
51            finish();
52        }
53    };
54
55}
56
57
58