|
|
|
@ -564,6 +564,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) {
|
|
|
|
@ -576,15 +583,23 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO add comments of this method
|
|
|
|
|
/**
|
|
|
|
|
* @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");
|
|
|
|
@ -594,7 +609,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) {
|
|
|
|
@ -608,10 +627,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) {
|
|
|
|
@ -724,6 +745,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) {
|
|
|
|
@ -776,6 +805,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();
|
|
|
|
|