1 package com.android.launcher2; 2 3 import android.content.Context; 4 import android.util.AttributeSet; 5 import android.view.KeyEvent; 6 import android.widget.EditText; 7 8 public class FolderEditText extends EditText { 9 10 private Folder mFolder; 11 12 public FolderEditText(Context context) { 13 super(context); 14 } 15 16 public FolderEditText(Context context, AttributeSet attrs) { 17 super(context, attrs); 18 } 19 20 public FolderEditText(Context context, AttributeSet attrs, int defStyle) { 21 super(context, attrs, defStyle); 22 } 23 24 public void setFolder(Folder folder) { 25 mFolder = folder; 26 } 27 28 @Override 29 public boolean onKeyPreIme(int keyCode, KeyEvent event) { 30 // Catch the back button on the soft keyboard so that we can just close the activity 31 if (event.getKeyCode() == android.view.KeyEvent.KEYCODE_BACK) { 32 mFolder.doneEditingFolderName(true); 33 } 34 return super.onKeyPreIme(keyCode, event); 35 } 36 } 37