mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-24 05:46:14 +03:00
#946 Allow to modify category in multi-select view
This commit is contained in:
parent
01c46004e7
commit
ae6d05243d
7 changed files with 50 additions and 19 deletions
|
@ -328,11 +328,7 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego
|
|||
if (frag != null) {
|
||||
manager.beginTransaction().remove(frag).commit();
|
||||
}
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putString(CategoryDialogFragment.PARAM_CATEGORY, note.getCategory());
|
||||
arguments.putLong(CategoryDialogFragment.PARAM_ACCOUNT_ID, note.getAccountId());
|
||||
CategoryDialogFragment categoryFragment = new CategoryDialogFragment();
|
||||
categoryFragment.setArguments(arguments);
|
||||
final DialogFragment categoryFragment = CategoryDialogFragment.newInstance(note.getAccountId(), note.getCategory());
|
||||
categoryFragment.setTargetFragment(this, 0);
|
||||
categoryFragment.show(manager, fragmentId);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package it.niedermann.owncloud.notes.edit.category;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
@ -13,7 +12,9 @@ import android.view.WindowManager;
|
|||
import android.widget.EditText;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -166,6 +167,14 @@ public class CategoryDialogFragment extends BrandedDialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
public static DialogFragment newInstance(long accountId, String category) {
|
||||
final DialogFragment categoryFragment = new CategoryDialogFragment();
|
||||
final Bundle arguments = new Bundle();
|
||||
arguments.putString(CategoryDialogFragment.PARAM_CATEGORY, category);
|
||||
arguments.putLong(CategoryDialogFragment.PARAM_ACCOUNT_ID, accountId);
|
||||
categoryFragment.setArguments(arguments);
|
||||
return categoryFragment;
|
||||
}
|
||||
|
||||
private class LoadCategoriesTask extends AsyncTask<String, Void, List<NavigationAdapter.CategoryNavigationItem>> {
|
||||
String currentSearchString;
|
||||
|
|
|
@ -61,6 +61,7 @@ import it.niedermann.owncloud.notes.branding.BrandingUtil;
|
|||
import it.niedermann.owncloud.notes.databinding.ActivityNotesListViewBinding;
|
||||
import it.niedermann.owncloud.notes.databinding.DrawerLayoutBinding;
|
||||
import it.niedermann.owncloud.notes.edit.EditNoteActivity;
|
||||
import it.niedermann.owncloud.notes.edit.category.CategoryDialogFragment;
|
||||
import it.niedermann.owncloud.notes.exception.ExceptionDialogFragment;
|
||||
import it.niedermann.owncloud.notes.main.NavigationAdapter.CategoryNavigationItem;
|
||||
import it.niedermann.owncloud.notes.main.NavigationAdapter.NavigationItem;
|
||||
|
@ -95,7 +96,7 @@ import static it.niedermann.owncloud.notes.shared.util.ColorUtil.contrastRatioIs
|
|||
import static it.niedermann.owncloud.notes.shared.util.SSOUtil.askForNewAccount;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class MainActivity extends LockedActivity implements NoteClickListener, ViewProvider, AccountPickerListener, AccountSwitcherListener {
|
||||
public class MainActivity extends LockedActivity implements NoteClickListener, ViewProvider, AccountPickerListener, AccountSwitcherListener, CategoryDialogFragment.CategoryDialogListener {
|
||||
|
||||
private static final String TAG = MainActivity.class.getSimpleName();
|
||||
|
||||
|
@ -983,4 +984,16 @@ public class MainActivity extends LockedActivity implements NoteClickListener, V
|
|||
mActionMode.finish();
|
||||
refreshLists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCategoryChosen(String category) {
|
||||
for (Integer i : new ArrayList<>(adapter.getSelected())) {
|
||||
DBNote note = (DBNote) adapter.getItem(i);
|
||||
note.setCategory(category);
|
||||
db.setCategory(ssoAccount, note, category, this::refreshLists);
|
||||
}
|
||||
|
||||
mActionMode.finish();
|
||||
refreshLists();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.List;
|
|||
import it.niedermann.owncloud.notes.R;
|
||||
import it.niedermann.owncloud.notes.branding.BrandedSnackbar;
|
||||
import it.niedermann.owncloud.notes.accountpicker.AccountPickerDialogFragment;
|
||||
import it.niedermann.owncloud.notes.edit.category.CategoryDialogFragment;
|
||||
import it.niedermann.owncloud.notes.main.items.ItemAdapter;
|
||||
import it.niedermann.owncloud.notes.persistence.NoteServerSyncHelper.ViewProvider;
|
||||
import it.niedermann.owncloud.notes.persistence.NotesDatabase;
|
||||
|
@ -133,7 +134,9 @@ public class MultiSelectedActionModeCallback implements Callback {
|
|||
}
|
||||
return true;
|
||||
case R.id.menu_move:
|
||||
AccountPickerDialogFragment.newInstance(currentLocalAccountId).show(fragmentManager, MainActivity.class.getSimpleName());
|
||||
AccountPickerDialogFragment
|
||||
.newInstance(currentLocalAccountId)
|
||||
.show(fragmentManager, MainActivity.class.getSimpleName());
|
||||
return true;
|
||||
case R.id.menu_share:
|
||||
final String subject = (adapter.getSelected().size() == 1)
|
||||
|
@ -152,6 +155,10 @@ public class MultiSelectedActionModeCallback implements Callback {
|
|||
}
|
||||
ShareUtil.openShareDialog(context, subject, noteContents.toString());
|
||||
return true;
|
||||
case R.id.menu_category:
|
||||
CategoryDialogFragment
|
||||
.newInstance(((DBNote) adapter.getItem(adapter.getSelected().get(0))).getAccountId(), "")
|
||||
.show(fragmentManager, CategoryDialogFragment.class.getSimpleName());
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package it.niedermann.owncloud.notes.shared.util.text;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class WwwLinksProcessor extends TextProcessor {
|
||||
|
|
|
@ -2,6 +2,13 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_category"
|
||||
android:icon="@drawable/ic_folder_grey600_24dp"
|
||||
android:orderInCategory="80"
|
||||
android:title="@string/menu_change_category"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_share"
|
||||
android:icon="@drawable/ic_share_white_24dp"
|
||||
|
@ -9,18 +16,18 @@
|
|||
android:title="@string/menu_share"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_delete"
|
||||
android:icon="@drawable/ic_delete_grey600_24dp"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/menu_delete"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_move"
|
||||
android:icon="@drawable/ic_send_grey600_24dp"
|
||||
android:orderInCategory="110"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/simple_move"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_delete"
|
||||
android:icon="@drawable/ic_delete_grey600_24dp"
|
||||
android:orderInCategory="110"
|
||||
android:title="@string/menu_delete"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
|
@ -1,2 +1,3 @@
|
|||
- Selecting a note in the main note list highlights two notes (#920) (@muety)
|
||||
- Support www links without protocol in preview mode (#949) (@muety)
|
||||
- Support www links without protocol in preview mode (#949) (@muety)
|
||||
- Allow to modify category in multi-select view (#946)
|
Loading…
Reference in a new issue