Make notes control set auto show and hide keyboard

pull/14/head
Sam Bosley 14 years ago
parent ec4e342177
commit 18061fbb50

@ -1,9 +1,12 @@
package com.todoroo.astrid.ui; package com.todoroo.astrid.ui;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.graphics.Color; import android.graphics.Color;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
@ -19,6 +22,8 @@ public class EditNotesControlSet extends PopupControlSet {
super(activity, viewLayout, displayViewLayout, R.string.TEA_note_label); super(activity, viewLayout, displayViewLayout, R.string.TEA_note_label);
editText = (EditText) getView().findViewById(R.id.notes); editText = (EditText) getView().findViewById(R.id.notes);
notesPreview = (TextView) getDisplayView().findViewById(R.id.notes_display); notesPreview = (TextView) getDisplayView().findViewById(R.id.notes_display);
dialog.getWindow()
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
} }
@Override @Override
@ -48,6 +53,20 @@ public class EditNotesControlSet extends PopupControlSet {
return null; return null;
} }
@Override
protected void onOkClick() {
super.onOkClick();
InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
}
@Override
protected void onCancelClick() {
super.onCancelClick();
InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
}
public boolean hasNotes() { public boolean hasNotes() {
return !TextUtils.isEmpty(editText.getText()); return !TextUtils.isEmpty(editText.getText());
} }

@ -32,14 +32,14 @@ public abstract class PopupControlSet extends TaskEditControlSet {
final DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() { final DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface d, int which) { public void onClick(DialogInterface d, int which) {
refreshDisplayView(); onOkClick();
} }
}; };
final DialogInterface.OnCancelListener cancelListener = new DialogInterface.OnCancelListener() { final DialogInterface.OnCancelListener cancelListener = new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface d) { public void onCancel(DialogInterface d) {
refreshDisplayView(); onCancelClick();
} }
}; };
@ -94,5 +94,13 @@ public abstract class PopupControlSet extends TaskEditControlSet {
}; };
} }
protected void onOkClick() {
refreshDisplayView();
}
protected void onCancelClick() {
refreshDisplayView();
}
protected abstract void refreshDisplayView(); protected abstract void refreshDisplayView();
} }

Loading…
Cancel
Save