1 /* 2 * Copyright (C) 2006 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.phone; 18 19 import android.app.Activity; 20 import android.content.Intent; 21 import android.net.Uri; 22 import android.os.Bundle; 23 import android.text.TextUtils; 24 import android.text.method.DigitsKeyListener; 25 import android.util.Log; 26 import android.view.View; 27 import android.widget.EditText; 28 29 /** 30 * Pin2 entry screen. 31 */ 32 public class GetPin2Screen extends Activity { 33 private static final String LOG_TAG = PhoneApp.LOG_TAG; 34 35 private EditText mPin2Field; 36 37 @Override 38 protected void onCreate(Bundle icicle) { 39 super.onCreate(icicle); 40 41 setContentView(R.layout.get_pin2_screen); 42 setupView(); 43 } 44 45 /** 46 * Reflect the changes in the layout that force the user to open 47 * the keyboard. 48 */ 49 private void setupView() { 50 mPin2Field = (EditText) findViewById(R.id.pin); 51 if (mPin2Field != null) { 52 mPin2Field.setKeyListener(DigitsKeyListener.getInstance()); 53 mPin2Field.setMovementMethod(null); 54 mPin2Field.setOnClickListener(mClicked); 55 } 56 } 57 58 private String getPin2() { 59 return mPin2Field.getText().toString(); 60 } 61 62 private void returnResult() { 63 Bundle map = new Bundle(); 64 map.putString("pin2", getPin2()); 65 66 Intent intent = getIntent(); 67 Uri uri = intent.getData(); 68 69 Intent action = new Intent(); 70 if (uri != null) action.setAction(uri.toString()); 71 setResult(RESULT_OK, action.putExtras(map)); 72 finish(); 73 } 74 75 private View.OnClickListener mClicked = new View.OnClickListener() { 76 public void onClick(View v) { 77 if (TextUtils.isEmpty(mPin2Field.getText())) { 78 return; 79 } 80 81 returnResult(); 82 } 83 }; 84 85 private void log(String msg) { 86 Log.d(LOG_TAG, "[GetPin2] " + msg); 87 } 88 } 89