1package com.android.launcher3;
2
3import android.content.Context;
4import android.util.AttributeSet;
5import android.view.KeyEvent;
6import android.widget.EditText;
7
8public 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