cmt: NotesListActivity.showCreatOrModifyFolderDialog

zhengkunpeng_branch
parent 7f090aff93
commit 7fb8a607a5

@ -561,6 +561,13 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
}
/**
* @Method showSoftInput
* @Date 2023/12/17 23:46
* @Author lenovo
* @Return void
* @Description
*/
private void showSoftInput() {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
@ -573,14 +580,23 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
/**
* @Method showCreateOrModifyFolderDialog
* @Date 2023/12/17 22:32
* @param create true false
* @Author lenovo
* @Return void
* @Description
*/
private void showCreateOrModifyFolderDialog(final boolean create) {
// final 关键字, 初始化之后无法修改 (const)
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null);
final EditText etName = (EditText) view.findViewById(R.id.et_foler_name);
showSoftInput();
if (!create) {
if (mFocusNoteDataItem != null) {
etName.setText(mFocusNoteDataItem.getSnippet());
etName.setText(mFocusNoteDataItem.getSnippet()); // 显示之前的名称
builder.setTitle(getString(R.string.menu_folder_change_name));
} else {
Log.e(TAG, "The long click data item is null");
@ -590,7 +606,11 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
etName.setText("");
builder.setTitle(this.getString(R.string.menu_create_folder));
}
/**
* OK
* Cancel
* lenovo 2023/12/18 0:03
*/
builder.setPositiveButton(android.R.string.ok, null);
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
@ -604,10 +624,12 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
public void onClick(View v) {
hideSoftInput(etName);
String name = etName.getText().toString();
// 如果该名称已经存在
if (DataUtils.checkVisibleFolderName(mContentResolver, name)) {
// 提示 exist, please rename
Toast.makeText(NotesListActivity.this, getString(R.string.folder_exist, name),
Toast.LENGTH_LONG).show();
etName.setSelection(0, etName.length());
etName.setSelection(0, etName.length()); //全选输入文件名(准备修改/删除)
return;
}
if (!create) {
@ -720,6 +742,14 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
super.onContextMenuClosed(menu);
}
/**
* @Method onContextItemSelected
* @Date 2023/12/17 23:51
* @param item
* @Author lenovo
* @Return boolean
* @Description
*/
@Override
public boolean onContextItemSelected(MenuItem item) {
if (mFocusNoteDataItem == null) {
@ -772,6 +802,14 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
return true;
}
/**
* @Method onOptionsItemSelected
* @Date 2023/12/17 23:49
* @param item
* @Author lenovo
* @Return boolean
* @Description
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();

Loading…
Cancel
Save