Small fix in Folder text editing

Change-Id: I65c6862cbbc125b197bb6afa4951b267373832e9
This commit is contained in:
Adam Cohen
2011-09-30 20:06:58 -07:00
parent 82ebbd2a2f
commit ea0818d475
+9 -11
View File
@@ -53,7 +53,8 @@ import java.util.ArrayList;
* Represents a set of icons chosen by the user or generated by the system.
*/
public class Folder extends LinearLayout implements DragSource, View.OnClickListener,
View.OnLongClickListener, DropTarget, FolderListener, TextView.OnEditorActionListener {
View.OnLongClickListener, DropTarget, FolderListener, TextView.OnEditorActionListener,
View.OnFocusChangeListener {
private static final String TAG = "Launcher.Folder";
@@ -148,6 +149,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mContent.setGridSize(0, 0);
mFolderName = (FolderEditText) findViewById(R.id.folder_name);
mFolderName.setFolder(this);
mFolderName.setOnFocusChangeListener(this);
// We find out how tall the text view wants to be (it is set to wrap_content), so that
// we can allocate the appropriate amount of space for it.
@@ -193,16 +195,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
}
}
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
mFolderName.getHitRect(mHitRect);
if (mHitRect.contains((int) ev.getX(), (int) ev.getY()) && !mIsEditingName) {
startEditingFolderName();
}
}
return false;
}
public boolean onLongClick(View v) {
Object tag = v.getTag();
if (tag instanceof ShortcutInfo) {
@@ -1024,4 +1016,10 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
public void getLocationInDragLayer(int[] loc) {
mLauncher.getDragLayer().getLocationInDragLayer(this, loc);
}
public void onFocusChange(View v, boolean hasFocus) {
if (v == mFolderName && hasFocus) {
startEditingFolderName();
}
}
}