Skip to content

Commit

Permalink
Remove "Rename category" (temporary solution)
Browse files Browse the repository at this point in the history
  • Loading branch information
akhbulatov committed Oct 10, 2016
1 parent 81b64a2 commit e05ede2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public long addRecord(String name) {
return mDatabase.insert(CategoryEntry.TABLE_NAME, null, values);
}

public boolean updateRecord(long rowId, String name) {
/* public boolean updateRecord(long rowId, String name) {
ContentValues values = createContentValues(name);
return mDatabase.update(CategoryEntry.TABLE_NAME, values,
CategoryEntry._ID + "=" + rowId, null) > 0;
}
} */

public boolean deleteRecord(long rowId) {
return mDatabase.delete(CategoryEntry.TABLE_NAME, CategoryEntry._ID + "=" + rowId, null) > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ public boolean onContextItemSelected(MenuItem item) {
ContextMenuRecyclerView.RecyclerContextMenuInfo info =
(ContextMenuRecyclerView.RecyclerContextMenuInfo) item.getMenuInfo();
switch (item.getItemId()) {
case R.id.menu_rename_category:
/* case R.id.menu_rename_category:
mSelectedItemId = info.id;
showCategoryEditorDialog(R.string.title_rename_category,
R.string.category_editor_action_rename,
R.string.category_editor_action_cancel);
return true;
return true; */
case R.id.menu_delete_category:
mSelectedItemId = info.id;
showCategoryDeleteConfirmDialog();
Expand Down Expand Up @@ -227,14 +227,14 @@ public void onFinishCategoryEditorDialog(DialogFragment dialog, int positiveText
// Add the category
if (positiveTextId == R.string.category_editor_action_add) {
addCategory(dialog);
} else {
} /* else {
// Edit the category
Dialog dialogView = dialog.getDialog();
EditText editName = (EditText) dialogView.findViewById(R.id.edit_category_name);
String name = editName.getText().toString();
renameCategory(name);
}
} */
}

// Confirms delete the category.
Expand Down Expand Up @@ -266,7 +266,7 @@ private void addCategory(DialogFragment dialog) {
}
}

private void renameCategory(String name) {
/* private void renameCategory(String name) {
if (name.isEmpty()) {
Toast.makeText(getActivity(),
R.string.error_category_editor_empty_field,
Expand All @@ -276,7 +276,7 @@ private void renameCategory(String name) {
mDbCategoryAdapter.updateRecord(mSelectedItemId, name);
getLoaderManager().restartLoader(LOADER_ID, null, this);
}
}
} */

private void deleteCategory() {
// First, deletes all words that are in the deleted category
Expand Down Expand Up @@ -309,14 +309,14 @@ private void showCategoryEditorDialog(int titleId, int positiveTextId, int negat

// Receives and shows data of the selected category to edit in the dialog
// Data is the name of the category
if (positiveTextId == R.string.category_editor_action_rename) {
/* if (positiveTextId == R.string.category_editor_action_rename) {
// NOTE! If the method is not called, the app crashes
getActivity().getSupportFragmentManager().executePendingTransactions();
Dialog dialogView = dialog.getDialog();
EditText editName = (EditText) dialogView.findViewById(R.id.edit_category_name);
editName.setText(getName());
}
} */
}

private void showCategoryDeleteConfirmDialog() {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/menu/selected_category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
<!-- <item
android:id="@+id/menu_rename_category"
android:title="@string/action_rename_category"
app:showAsAction="never" />
app:showAsAction="never" /> -->

<item
android:id="@+id/menu_delete_category"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@

<!-- The dialog "Category editor" -->
<string name="title_new_category">Новая категория</string>
<string name="title_rename_category">Переименование категории</string>
<!-- <string name="title_rename_category">Переименование категории</string> -->
<string name="category_editor_name_hint">Название</string>
<string name="category_editor_action_add">Добавить</string>
<string name="category_editor_action_rename">Переименовать</string>
<!-- <string name="category_editor_action_rename">Переименовать</string> -->
<string name="category_editor_action_cancel">Отмена</string>
<string name="error_category_editor_empty_field">Поле не заполнено</string>

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@

<!-- The dialog "Category editor" -->
<string name="title_new_category">New category</string>
<string name="title_rename_category">Rename category</string>
<!-- <string name="title_rename_category">Rename category</string> -->
<string name="category_editor_name_hint">Name</string>
<string name="category_editor_action_add">Add</string>
<string name="category_editor_action_rename">Rename</string>
<!-- <string name="category_editor_action_rename">Rename</string> -->
<string name="category_editor_action_cancel">Cancel</string>
<string name="error_category_editor_empty_field">The field is not filled</string>

Expand Down

0 comments on commit e05ede2

Please sign in to comment.