Skip to content

Commit 228b2bf

Browse files
committed
added path to DialogItem
1 parent 863bdbd commit 228b2bf

File tree

4 files changed

+43
-23
lines changed

4 files changed

+43
-23
lines changed

app/src/main/java/ru/fazziclay/opentoday/ui/dialog/DialogItem.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class DialogItem {
6868

6969
// Edit
7070
private final List<BaseEditUiModule> editModules = new ArrayList<>();
71+
private String path;
7172

7273
public DialogItem(Activity activity, ItemManager itemManager) {
7374
this.activity = activity;
@@ -76,16 +77,17 @@ public DialogItem(Activity activity, ItemManager itemManager) {
7677

7778
public void create(Class<? extends Item> type, OnEditDone onEditDone) {
7879
Item item = ItemsRegistry.REGISTRY.getItemInfoByClass(type).create();
79-
show(item, true, onEditDone);
80+
show(item, "unsupported", true, onEditDone);
8081
}
8182

82-
public void edit(Item item) {
83-
show(item, false, null);
83+
public void edit(Item item, String path) {
84+
show(item, path, false, null);
8485
}
8586

86-
private void show(Item item, boolean create, OnEditDone onEditDone) {
87+
private void show(Item item, String path, boolean create, OnEditDone onEditDone) {
8788
cancel();
8889
this.item = item;
90+
this.path = path;
8991
this.create = create;
9092
this.onEditDone = onEditDone;
9193
this.canceled = false;
@@ -100,6 +102,7 @@ private void show(Item item, boolean create, OnEditDone onEditDone) {
100102
private View generateView() {
101103
DialogItemFrameBinding binding = DialogItemFrameBinding.inflate(this.activity.getLayoutInflater());
102104

105+
binding.path.setText(path != null ? path : "unsupported");
103106
if (item instanceof Item) {
104107
binding.canvas.addView(addEditModule(new ItemEditModule()));
105108
}
@@ -237,7 +240,7 @@ public abstract static class BaseEditUiModule {
237240
public void notifyCreateMode() {}
238241
}
239242

240-
public static class ItemEditModule extends BaseEditUiModule {
243+
public class ItemEditModule extends BaseEditUiModule {
241244
private DialogItemModuleItemBinding binding;
242245
private Runnable onEditStart;
243246

@@ -292,6 +295,7 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
292295
binding.minimize.setOnClickListener(v -> onEditStart.run());
293296
//
294297

298+
binding.editNotifications.setEnabled(!DialogItem.this.create);
295299
binding.editNotifications.setOnClickListener(v -> new DialogItemNotificationsEditor(activity, item, () -> updateNotificationPreview(item, activity)).show());
296300
updateNotificationPreview(item, activity);
297301
}
@@ -489,7 +493,7 @@ public void notifyCreateMode() {
489493
}
490494
}
491495

492-
public static class CycleListItemEditModule extends BaseEditUiModule {
496+
public class CycleListItemEditModule extends BaseEditUiModule {
493497
private DialogItemModuleCyclelistBinding binding;
494498
private SimpleSpinnerAdapter<CycleListItem.TickBehavior> simpleSpinnerAdapter;
495499
private Runnable onEditStart;
@@ -505,10 +509,8 @@ public void setup(Item item, Activity activity, View view) {
505509
CycleListItem cycleListItem = (CycleListItem) item;
506510

507511
binding = DialogItemModuleCyclelistBinding.inflate(activity.getLayoutInflater(), (ViewGroup) view, false);
508-
fcu_viewOnClick(binding.externalEditor, () -> {
509-
// TODO: 29.08.2022 path unsupported fix
510-
new DialogItemStorageEditor(activity, App.get(activity).getItemManager(), cycleListItem.getItemsCycleStorage(), null, "unsupported").show();
511-
});
512+
binding.externalEditor.setEnabled(!DialogItem.this.create);
513+
fcu_viewOnClick(binding.externalEditor, () -> new DialogItemStorageEditor(activity, App.get(activity).getItemManager(), cycleListItem.getItemsCycleStorage(), null, DialogItem.this.path).show());
512514
simpleSpinnerAdapter = new SimpleSpinnerAdapter<CycleListItem.TickBehavior>(activity)
513515
.add(activity.getString(R.string.cycleListItem_tick_all), CycleListItem.TickBehavior.ALL)
514516
.add(activity.getString(R.string.cycleListItem_tick_current), CycleListItem.TickBehavior.CURRENT);
@@ -585,7 +587,7 @@ public void setOnStartEditListener(Runnable o) {
585587
}
586588
}
587589

588-
private static class GroupItemEditModule extends BaseEditUiModule {
590+
private class GroupItemEditModule extends BaseEditUiModule {
589591
private DialogItemModuleGroupBinding binding;
590592

591593
@Override
@@ -597,10 +599,8 @@ public View getView() {
597599
public void setup(Item item, Activity activity, View view) {
598600
GroupItem groupItem = (GroupItem) item;
599601
binding = DialogItemModuleGroupBinding.inflate(activity.getLayoutInflater(), (ViewGroup) view, false);
600-
fcu_viewOnClick(binding.externalEditor, () -> {
601-
// TODO: 29.08.2022 path unsupported fix
602-
new DialogItemStorageEditor(activity, App.get(activity).getItemManager(), groupItem.getItemStorage(), null, "unsupported").show();
603-
});
602+
binding.externalEditor.setEnabled(!DialogItem.this.create);
603+
fcu_viewOnClick(binding.externalEditor, () -> new DialogItemStorageEditor(activity, App.get(activity).getItemManager(), groupItem.getItemStorage(), null, DialogItem.this.path).show());
604604
}
605605

606606
@Override
@@ -610,7 +610,7 @@ public void commit(Item item) {}
610610
public void setOnStartEditListener(Runnable o) { }
611611
}
612612

613-
private static class FilterGroupItemEditModule extends BaseEditUiModule {
613+
private class FilterGroupItemEditModule extends BaseEditUiModule {
614614
private DialogItemModuleFiltergroupBinding binding;
615615

616616
@Override
@@ -622,10 +622,8 @@ public View getView() {
622622
public void setup(Item item, Activity activity, View view) {
623623
FilterGroupItem fGroupItem = (FilterGroupItem) item;
624624
binding = DialogItemModuleFiltergroupBinding.inflate(activity.getLayoutInflater(), (ViewGroup) view, false);
625-
fcu_viewOnClick(binding.externalEditor, () -> {
626-
// TODO: 29.08.2022 path unsupported fix
627-
new DialogFilterGroupEdit(activity, fGroupItem, "unsupported").show();
628-
});
625+
binding.externalEditor.setEnabled(!DialogItem.this.create);
626+
fcu_viewOnClick(binding.externalEditor, () -> new DialogFilterGroupEdit(activity, fGroupItem, DialogItem.this.path).show());
629627
}
630628

631629
@Override

app/src/main/java/ru/fazziclay/opentoday/ui/other/item/ItemStorageDrawer.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,16 @@ public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction)
261261
private void actionItem(Item item, ItemManager.ItemAction action) {
262262
switch (action) {
263263
case OPEN_EDIT_DIALOG:
264-
dialogItem.edit(item);
264+
String name = "Unknown";
265+
if (item instanceof TextItem) {
266+
TextItem t = (TextItem) item;
267+
name = t.getText();
268+
}
269+
dialogItem.edit(item, ItemViewGenerator.appendPath(path, name));
265270
break;
266271

267272
case SELECT_ON:
268-
itemManager.selectItem(new Selection(itemStorage, item)); item.visibleChanged();
273+
itemManager.selectItem(new Selection(itemStorage, item));
269274
item.visibleChanged();
270275
break;
271276

@@ -352,7 +357,12 @@ private void showRightMenu(Item item, View itemView) {
352357
}
353358

354359
DialogItem dialogItem = new DialogItem(activity, itemManager);
355-
dialogItem.edit(copyItem);
360+
String text = "Unknown";
361+
if (copyItem instanceof TextItem) {
362+
TextItem t = (TextItem) copyItem;
363+
text = t.getText();
364+
}
365+
dialogItem.edit(copyItem, ItemViewGenerator.appendPath(path, text));
356366

357367
int createPos = itemStorage.getItemPosition(copyItem);
358368
if (createPos != (currPos + 1)) itemStorage.move(createPos, currPos + 1);

app/src/main/java/ru/fazziclay/opentoday/ui/other/item/ItemViewGenerator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,4 +280,9 @@ private String appendPath(String localPath) {
280280
if (this.path == null) return null;
281281
return this.path + (this.path.endsWith("/") ? "" : "/") + "(" + localPath + ")";
282282
}
283+
284+
public static String appendPath(String path, String localPath) {
285+
if (path == null) return null;
286+
return path + (path.endsWith("/") ? "" : "/") + "(" + localPath + ")";
287+
}
283288
}

app/src/main/res/layout/dialog_item_frame.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
android:orientation="vertical"
77
android:padding="5sp">
88

9+
<TextView
10+
android:id="@+id/path"
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content"
13+
android:textSize="16sp"
14+
tools:text="/text/stes" />
15+
916
<ScrollView
1017
android:layout_width="match_parent"
1118
android:layout_height="match_parent"

0 commit comments

Comments
 (0)