|
|
@ -21,8 +21,11 @@ package org.isoron.uhabits.core.ui.screens.habits.show;
|
|
|
|
|
|
|
|
|
|
|
|
import android.support.annotation.*;
|
|
|
|
import android.support.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.isoron.uhabits.core.commands.CommandRunner;
|
|
|
|
|
|
|
|
import org.isoron.uhabits.core.commands.DeleteHabitsCommand;
|
|
|
|
import org.isoron.uhabits.core.models.*;
|
|
|
|
import org.isoron.uhabits.core.models.*;
|
|
|
|
import org.isoron.uhabits.core.tasks.*;
|
|
|
|
import org.isoron.uhabits.core.tasks.*;
|
|
|
|
|
|
|
|
import org.isoron.uhabits.core.ui.callbacks.OnConfirmedCallback;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
import java.io.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
@ -45,18 +48,23 @@ public class ShowHabitMenuBehavior
|
|
|
|
@NonNull
|
|
|
|
@NonNull
|
|
|
|
private System system;
|
|
|
|
private System system;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
|
|
|
|
private CommandRunner commandRunner;
|
|
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
@Inject
|
|
|
|
public ShowHabitMenuBehavior(@NonNull HabitList habitList,
|
|
|
|
public ShowHabitMenuBehavior(@NonNull HabitList habitList,
|
|
|
|
@NonNull Habit habit,
|
|
|
|
@NonNull Habit habit,
|
|
|
|
@NonNull TaskRunner taskRunner,
|
|
|
|
@NonNull TaskRunner taskRunner,
|
|
|
|
@NonNull Screen screen,
|
|
|
|
@NonNull Screen screen,
|
|
|
|
@NonNull System system)
|
|
|
|
@NonNull System system,
|
|
|
|
|
|
|
|
@NonNull CommandRunner commandRunner)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.habitList = habitList;
|
|
|
|
this.habitList = habitList;
|
|
|
|
this.habit = habit;
|
|
|
|
this.habit = habit;
|
|
|
|
this.taskRunner = taskRunner;
|
|
|
|
this.taskRunner = taskRunner;
|
|
|
|
this.screen = screen;
|
|
|
|
this.screen = screen;
|
|
|
|
this.system = system;
|
|
|
|
this.system = system;
|
|
|
|
|
|
|
|
this.commandRunner = commandRunner;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void onEditHabit()
|
|
|
|
public void onEditHabit()
|
|
|
@ -77,9 +85,21 @@ public class ShowHabitMenuBehavior
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void onDeleteHabit()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
List<Habit> selected = Collections.singletonList(habit);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
screen.showDeleteConfirmationScreen(() -> {
|
|
|
|
|
|
|
|
commandRunner.execute(new DeleteHabitsCommand(habitList, selected),
|
|
|
|
|
|
|
|
null);
|
|
|
|
|
|
|
|
screen.showMessage(Message.HABIT_DELETED);
|
|
|
|
|
|
|
|
screen.endActivity();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public enum Message
|
|
|
|
public enum Message
|
|
|
|
{
|
|
|
|
{
|
|
|
|
COULD_NOT_EXPORT
|
|
|
|
COULD_NOT_EXPORT, HABIT_DELETED
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public interface Screen
|
|
|
|
public interface Screen
|
|
|
@ -89,6 +109,11 @@ public class ShowHabitMenuBehavior
|
|
|
|
void showMessage(Message m);
|
|
|
|
void showMessage(Message m);
|
|
|
|
|
|
|
|
|
|
|
|
void showSendFileScreen(String filename);
|
|
|
|
void showSendFileScreen(String filename);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void showDeleteConfirmationScreen(
|
|
|
|
|
|
|
|
@NonNull OnConfirmedCallback callback);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void endActivity();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public interface System
|
|
|
|
public interface System
|
|
|
|